I use the pyqt5.I connect the pushbutton
signal to the dididi()
. It is supported when I clicked the button it will print the message, but when I click the button, it does not print the message. Why? What can I do to solve it?
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'bank1.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import QBasicTimer
from PyQt5.QtGui import QColor, QFontMetrics, QPainter, QPalette
from PyQt5.QtWidgets import (QApplication, QDialog, QLineEdit, QVBoxLayout,
QWidget)
from PyQt5.QtCore import QCoreApplication
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(400, 300)
self.pushButton = QtWidgets.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(80, 200, 71, 21))
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QtWidgets.QPushButton(Form)
self.pushButton_2.setGeometry(QtCore.QRect(230, 200, 72, 23))
self.pushButton_2.setObjectName("pushButton_2")
self.textEdit = QtWidgets.QTextEdit(Form)
self.textEdit.setGeometry(QtCore.QRect(140, 90, 104, 31))
self.textEdit.setObjectName("textEdit")
self.pushButton.clicked.connect(self.dididi)
self.pushButton_2.clicked.connect(self.dididi)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "RCT"))
self.pushButton.setText(_translate("Form", "θΏζ₯"))
self.pushButton_2.setText(_translate("Form", "ει"))
def dididi(self):
print("hello world")
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
widget = QWidget(None)
Ui_Form().setupUi(widget)
widget.show()
sys.exit(app.exec_())
pass