189 8069 5689

认识PyQt5-HelloWorld

from PyQt5.Qt import *
import sys

class Window(QWidget):
    def __init__(self, title):
        self.title = title
        super().__init__()
        self.initUI()
        self.setGeometry(300, 200, 300, 200)
        self.setWindowTitle(self.title)
        self.show()

    def initUI(self):
        btn = QPushButton()
        btn.setParent(self)
        btn.setText("我是按钮")
        btn.clicked.connect(self.helloWolrd)

    def helloWolrd(self):
        print("这是我的第一个PyQt程序")

if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = Window("I AM AESCR")
    sys.exit(app.exec_())

本文题目:认识PyQt5-HelloWorld
网页地址:http://cdxtjz.cn/article/gseiph.html

其他资讯