1.源代码
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton,QLabel
class Test(QWidget):
def __init__(self):
super(Test, self).__init__()
self.button = QPushButton('显示', self)
self.button.resize(80,40)
self.button.move(500,250)
self.label=QLabel(self)
self.label.resize(200,20)
self.button.clicked.connect(self.show_text)
def show_text(self):
self.label.setText('相应按钮文本显示!')
if __name__ == '__main__':
app = QApplication(sys.argv)
test = Test()
test.show()
sys.exit(app.exec_())
2.运行结果