I'm making a simple UI in pyqt5 with using QtDesigner. When i run the program, pushbutton's click event works as its suppose to in first time. However when i click for the second time. It exits from the program with an exit code.
class Main(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
loadUi('SqdhelpContentSearcher.ui', self)
self.show()
self.starter()
def starter(self):
try:
self.conn = sqlite3.connect('contest_details.db')
self.c = self.conn.cursor()
self.pushButton.clicked.connect(self.search)
except:
self.textEdit_2.setText(sys.exc_info()[0])
def search(self):
word = self.lineEdit.text()
output = ''
try:
self.c.execute(f"""SELECT * FROM ContestWinners WHERE ContestLink LIKE '%{word}%'""")
for row in self.c.fetchall():
output += f'{row[1]} - {row[2]} - {row[3]} \n'
output += '--------------------------------------------------------------------------------- \n'
self.textEdit.setText(output)
except:
self.textEdit_2.setText(sys.exc_info()[0])
finally:
self.conn.close()
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
m = Main()
sys.exit(app.exec_())
Result:
Process finished with exit code -1073740791 (0xC0000409)
User contributions licensed under CC BY-SA 3.0