PyQt5 - PushButton gives error in second click

0

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)
python
pyqt5
qt-designer
qpushbutton
asked on Stack Overflow May 24, 2020 by cleancode13 • edited May 24, 2020 by eyllanesc

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0