I wanna to do a chat application when the user typing a URL or mail text will become hyperlink google.com
/ abc123@gmail.com
similar like Whatsapp and Facebook Messenger. But now my code can't type anything will get the error:
RecursionError: maximum recursion depth exceeded in comparison Fatal Python error: Cannot recover from stack overflow.
I have no idea how to fix this problem. I research Google doesn't get any help for me.
from PyQt5 import QtCore, QtGui, QtWidgets
import re
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(400, 300)
self.textBrowser = QtWidgets.QTextBrowser(Form)
self.textBrowser.setGeometry(QtCore.QRect(20, 10, 361, 192))
self.textBrowser.setObjectName("textBrowser")
self.pushButton = QtWidgets.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(300, 220, 93, 28))
self.pushButton.setObjectName("pushButton")
self.textEdit = QtWidgets.QTextEdit(Form)
self.textEdit.setGeometry(QtCore.QRect(20, 210, 271, 41))
self.textEdit.setObjectName("textEdit")
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
self.pushButton.clicked.connect(self.getvalue)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.pushButton.setText(_translate("Form", "PushButton"))
def getvalue(self,email):
s = self.textEdit.toPlainText()
p = re.match("^.+@(\[?)[a-zA-Z0-9-.]+.([a-zA-Z]{2,3}|[0-9]{1,3})(]?)$",str (email))
q = re.compile("^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$",re.IGNORECASE)
if (p != None and self.getvalue(s) == True):
links ='{1}'.format(('mailto:'+s), s)
self.textBrowser.setOpenExternalLinks(True)
self.textBrowser.setText(links)
print("s")
elif (q != None and self.getvalue(s) == True):
link ='{1}'.format(('http://'+s), s)
self.textBrowser.setOpenExternalLinks(True)
self.textBrowser.setText(link)
print("t")
else:
self.textBrowser.append(s)
print("u")
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_Form()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
Blockquote
The result :
Traceback (most recent call last): File "c:\Users\User.vscode\extensions\ms-python.python-2018.12.1\pythonFiles\lib\python\ptvsd_vendored\pydevd_pydevd_bundle\pydevd_trace_dispatch_regular.py", line 373, in call if not is_stepping and frame_cache_key in cache_skips: RecursionError: maximum recursion depth exceeded in comparison Fatal Python error: Cannot recover from stack overflow.
Thread 0x00003700 (most recent call first): File "c:\Users\User.vscode\extensions\ms-python.python-2018.12.1\pythonFiles\lib\python\ptvsd_vendored\pydevd\pydevd.py", line 176 in _on_run File "c:\Users\User.vscode\extensions\ms-python.python-2018.12.1\pythonFiles\lib\python\ptvsd_vendored\pydevd_pydevd_bundle\pydevd_comm.py", line 203 in run File "C:\Program Files (x86)\Python37-32\lib\threading.py", line 917 in _bootstrap_inner
File "C:\Program Files (x86)\Python37-32\lib\threading.py", line 885 in _bootstrap File "c:\Users\User.vscode\extensions\ms-python.python-2018.12.1\pythonFiles\lib\python\ptvsd_vendored\pydevd_pydev_bundle\pydev_monkey.py", line 626 in callThread 0x000029a4 (most recent call first): File "C:\Program Files (x86)\Python37-32\lib\threading.py", line 300 in wait File "C:\Program Files (x86)\Python37-32\lib\threading.py", line 552 in wait File "c:\Users\User.vscode\extensions\ms-python.python-2018.12.1\pythonFiles\lib\python\ptvsd_vendored\pydevd\pydevd.py", line 154 in _on_run File "c:\Users\User.vscode\extensions\ms-python.python-2018.12.1\pythonFiles\lib\python\ptvsd_vendored\pydevd_pydevd_bundle\pydevd_comm.py", line 203 in run File "C:\Program Files (x86)\Python37-32\lib\threading.py", line 917 in _bootstrap_inner
File "C:\Program Files (x86)\Python37-32\lib\threading.py", line 885 in _bootstrap File "c:\Users\User.vscode\extensions\ms-python.python-2018.12.1\pythonFiles\lib\python\ptvsd_vendored\pydevd_pydev_bundle\pydev_monkey.py", line 626 in callThread 0x00003c94 (most recent call first): File "c:\Users\User.vscode\extensions\ms-python.python-2018.12.1\pythonFiles\lib\python\ptvsd\wrapper.py", line 383 in recv File "c:\Users\User.vscode\extensions\ms-python.python-2018.12.1\pythonFiles\lib\python\ptvsd_vendored\pydevd_pydevd_bundle\pydevd_comm.py", line 273 in _on_run File "c:\Users\User.vscode\extensions\ms-python.python-2018.12.1\pythonFiles\lib\python\ptvsd_vendored\pydevd_pydevd_bundle\pydevd_comm.py", line 203 in run File "C:\Program Files (x86)\Python37-32\lib\threading.py", line 917 in _bootstrap_inner
File "C:\Program Files (x86)\Python37-32\lib\threading.py", line 885 in _bootstrapThread 0x00001318 (most recent call first): File "c:\Users\User.vscode\extensions\ms-python.python-2018.12.1\pythonFiles\lib\python\ptvsd\ipcjson.py", line 112 in _send File "c:\Users\User.vscode\extensions\ms-python.python-2018.12.1\pythonFiles\lib\python\ptvsd\ipcjson.py", line 279 in send_event File "c:\Users\User.vscode\extensions\ms-python.python-2018.12.1\pythonFiles\lib\python\ptvsd\wrapper.py", line 2558 in on_pydevd_cmd_write_to_console2 File "c:\Users\User.vscode\extensions\ms-python.python-2018.12.1\pythonFiles\lib\python\ptvsd\wrapper.py", line 1386 in on_pydevd_event File "c:\Users\User.vscode\extensions\ms-python.python-2018.12.1\pythonFiles\lib\python\ptvsd\session.py", line 181 in handle_pydevd_message File "c:\Users\User.vscode\extensions\ms-python.python-2018.12.1\pythonFiles\lib\python\ptvsd\daemon.py", line 531 in _handle_pydevd_message File "c:\Users\User.vscode\extensions\ms-python.python-2018.12.1\pythonFiles\lib\python\ptvsd\wrapper.py", line 423 in send File "c:\Users\User.vscode\extensions\ms-python.python-2018.12.1\pythonFiles\lib\python\ptvsd_vendored\pydevd_pydevd_bundle\pydevd_comm.py", line 522 in send File "c:\Users\User.vscode\extensions\ms-python.python-2018.12.1\pythonFiles\lib\python\ptvsd_vendored\pydevd_pydevd_bundle\pydevd_comm.py", line 365 in _on_run File "c:\Users\User.vscode\extensions\ms-python.python-2018.12.1\pythonFiles\lib\python\ptvsd_vendored\pydevd_pydevd_bundle\pydevd_comm.py", line 203 in run File "C:\Program Files (x86)\Python37-32\lib\threading.py", line 917 in _bootstrap_inner
File "C:\Program Files (x86)\Python37-32\lib\threading.py", line 885 in _bootstrapThread 0x00002658 (most recent call first): File "c:\Users\User.vscode\extensions\ms-python.python-2018.12.1\pythonFiles\lib\python\ptvsd\ipcjson.py", line 131 in _buffered_read_line_as_ascii File "c:\Users\User.vscode\extensions\ms-python.python-2018.12.1\pythonFiles\lib\python\ptvsd\ipcjson.py", line 172 in _wait_for_message File "c:\Users\User.vscode\extensions\ms-python.python-2018.12.1\pythonFiles\lib\python\ptvsd\ipcjson.py", line 318 in process_one_message File "c:\Users\User.vscode\extensions\ms-python.python-2018.12.1\pythonFiles\lib\python\ptvsd\ipcjson.py", line 305 in process_messages File "c:\Users\User.vscode\extensions\ms-python.python-2018.12.1\pythonFiles\lib\python\ptvsd\wrapper.py", line 906 in process_messages File "C:\Program Files (x86)\Python37-32\lib\threading.py", line 865 in run File "C:\Program Files (x86)\Python37-32\lib\threading.py", line 917 in _bootstrap_inner File "C:\Program Files (x86)\Python37-32\lib\threading.py", line 885 in _bootstrap
Thread 0x00000df0 (most recent call first): File "C:\Program Files (x86)\Python37-32\lib\threading.py", line 300 in wait File "C:\Program Files (x86)\Python37-32\lib\threading.py", line 552 in wait File "c:\Users\User.vscode\extensions\ms-python.python-2018.12.1\pythonFiles\lib\python\ptvsd\futures.py", line 106 in run_forever File "C:\Program Files (x86)\Python37-32\lib\threading.py", line 865 in run File "C:\Program Files (x86)\Python37-32\lib\threading.py", line 917 in _bootstrap_inner File "C:\Program Files (x86)\Python37-32\lib\threading.py", line 885 in _bootstrap
Current thread 0x00001154 (most recent call first): File "c:\Users\User.vscode\extensions\ms-python.python-2018.12.1\pythonFiles\lib\python\ptvsd_vendored\pydevd_pydevd_bundle\pydevd_trace_dispatch_regular.py", line 373 in call File "C:\Program Files (x86)\Python37-32\lib\enum.py", line 607 in value File "C:\Program Files (x86)\Python37-32\lib\types.py", line 171 in get File "C:\Program Files (x86)\Python37-32\lib\re.py", line 274 in _compile
File "C:\Program Files (x86)\Python37-32\lib\re.py", line 234 in compile File "c:\Users\User\Desktop\python\test.py", line 42 in getvalue File "c:\Users\User\Desktop\python\test.py", line 48 in getvalue File "c:\Users\User\Desktop\python\test.py", line 48 in getvalue ...
User contributions licensed under CC BY-SA 3.0