PyQt5 'Process finished with exit code -1073740791 (0xC0000409)'

0

so I'm trying to build a MySQL database editor using PyQt5 and Qt designer and I've defined a button to run a custom method for connection but every time I press the button connection won't happen, app closes and then I get 'Process finished with exit code -1073740791 (0xC0000409)'

Things I've tried:

  • using mysql.connector instead of sqlalchemy
  • rolling back my graphic card driver (my laptop has two graphic card i don't know which one does the PyCharm uses but i rolled back the main one)
from PyQt5 import QtCore, QtGui, QtWidgets
from mysql.connector import connect


class Ui_Form(object):

    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(350, 200)
        Form.setMinimumSize(QtCore.QSize(350, 200))
        Form.setMaximumSize(QtCore.QSize(350, 200))
        Form.setSizeIncrement(QtCore.QSize(0, 0))
        Form.setBaseSize(QtCore.QSize(0, 0))
        Form.setMouseTracking(False)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap("proxy.duckduckgo.com.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        Form.setWindowIcon(icon)
        self.gridLayout = QtWidgets.QGridLayout(Form)
        self.gridLayout.setObjectName("gridLayout")
        self.PortLabel = QtWidgets.QLabel(Form)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(10)
        self.PortLabel.setFont(font)
        self.PortLabel.setObjectName("PortLabel")
        self.gridLayout.addWidget(self.PortLabel, 1, 0, 1, 1)
        self.CancelBtn = QtWidgets.QPushButton(Form)
        self.CancelBtn.setObjectName("CancelBtn")
        self.CancelBtn.clicked.connect(self.exit)
        self.gridLayout.addWidget(self.CancelBtn, 5, 2, 1, 1)
        self.DBLabel = QtWidgets.QLabel(Form)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(10)
        self.DBLabel.setFont(font)
        self.DBLabel.setObjectName("DBLabel")
        self.gridLayout.addWidget(self.DBLabel, 4, 0, 1, 1)
        self.UserLabel = QtWidgets.QLabel(Form)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(10)
        self.UserLabel.setFont(font)
        self.UserLabel.setObjectName("UserLabel")
        self.gridLayout.addWidget(self.UserLabel, 2, 0, 1, 1)
        self.HostLabel = QtWidgets.QLabel(Form)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(10)
        self.HostLabel.setFont(font)
        self.HostLabel.setObjectName("HostLabel")
        self.gridLayout.addWidget(self.HostLabel, 0, 0, 1, 1)
        self.PassLabel = QtWidgets.QLabel(Form)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(10)
        self.PassLabel.setFont(font)
        self.PassLabel.setObjectName("PassLabel")
        self.gridLayout.addWidget(self.PassLabel, 3, 0, 1, 1)
        self.SubmitBtn = QtWidgets.QPushButton(Form)
        self.SubmitBtn.setObjectName("SubmitBtn")
        self.SubmitBtn.clicked.connect(self.connect_to_database)
        self.gridLayout.addWidget(self.SubmitBtn, 5, 3, 1, 1)
        self.HostLineEdit = QtWidgets.QLineEdit(Form)
        self.HostLineEdit.setObjectName("HostLineEdit")
        self.gridLayout.addWidget(self.HostLineEdit, 0, 1, 1, 3)
        self.PortLineEdit = QtWidgets.QLineEdit(Form)
        self.PortLineEdit.setObjectName("PortLineEdit")
        self.gridLayout.addWidget(self.PortLineEdit, 1, 1, 1, 3)
        self.UserLineEdit = QtWidgets.QLineEdit(Form)
        self.UserLineEdit.setObjectName("UserLineEdit")
        self.gridLayout.addWidget(self.UserLineEdit, 2, 1, 1, 3)
        self.PassLineEdit = QtWidgets.QLineEdit(Form)
        self.PassLineEdit.setObjectName("PassLineEdit")
        self.gridLayout.addWidget(self.PassLineEdit, 3, 1, 1, 3)
        self.DBLineEdit = QtWidgets.QLineEdit(Form)
        self.DBLineEdit.setObjectName("DBLineEdit")
        self.gridLayout.addWidget(self.DBLineEdit, 4, 1, 1, 3)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "Connection Details"))
        self.PortLabel.setText(_translate("Form", "<html><head/><body><p align=\"center\">Port</p></body></html>"))
        self.CancelBtn.setText(_translate("Form", "Cancel"))
        self.DBLabel.setText(_translate("Form", "<html><head/><body><p align=\"center\">Database</p></body></html>"))
        self.UserLabel.setText(_translate("Form", "<html><head/><body><p align=\"center\">Username</p></body></html>"))
        self.HostLabel.setText(_translate("Form", "<html><head/><body><p align=\"center\">Host</p></body></html>"))
        self.PassLabel.setText(_translate("Form", "<html><head/><body><p align=\"center\">Password</p></body></html>"))
        self.SubmitBtn.setText(_translate("Form", "Submit"))

    def connect_to_database(self):
        connect(host=self.HostLineEdit,
                port=self.PortLineEdit,
                user=self.UserLineEdit,
                passwd=self.PassLineEdit,
                database=self.DBLineEdit)
        print('Connected')

    def exit(self):
        sys.exit()


if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    Form = QtWidgets.QWidget()
    ui = Ui_Form()
    ui.setupUi(Form)
    Form.show()
    sys.exit(app.exec_())

python
python-3.x
pyqt
pyqt5
asked on Stack Overflow Jul 13, 2019 by Kasi • edited Jul 13, 2019 by Kasi

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0