python:Process finished with exit code (0xC0000409) when using Pycharm and PyQt5

-1

I tried to write a button event by using pyqt5 and python, but the program reports an error when I press the button

test2.py

from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(400, 300)
        self.plainTextEdit = QtWidgets.QPlainTextEdit(Form)
        self.plainTextEdit.setGeometry(QtCore.QRect(110, 120, 104, 64))
        self.plainTextEdit.setObjectName("plainTextEdit")
        self.pushButton = QtWidgets.QPushButton(Form)
        self.pushButton.setGeometry(QtCore.QRect(130, 60, 62, 19))
        self.pushButton.setObjectName("pushButton")

        self.retranslateUi(Form)
        self.pushButton.clicked.connect(Form.BtnClick)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "Form"))
        self.pushButton.setText(_translate("Form", "PushButton"))


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_())

test2Index.py

import sys
from PyQt5 import QtCore, QtWidgets
from test2 import Ui_Form

class index(QtWidgets.QMainWindow,Ui_Form):
    def __init__(self):
        super(index,self).__init__()
        self.setupUi(self)

    def BtnClick(self):
        self.plainTextEdit.setText("aa")

if __name__ == "__main__":

    QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
    app = QtWidgets.QApplication(sys.argv)
    window = index()
    window.show()
    sys.exit(app.exec_())

when i run testIndex.py and press the button it appears: Process finished with exit code -1073740791 (0xC0000409)

python
pyqt5
asked on Stack Overflow Nov 28, 2019 by OlW

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0