pyqt5信号与槽实现

1.源代码

pyqt5信号与槽实现_第1张图片

#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName  :label.py
# @Time      :2020/2/19 18:55
# @Author    :青松


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.运行结果

pyqt5信号与槽实现_第2张图片

你可能感兴趣的:(Pyqt5开发)