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://jkwzsj.com/article/gseiph.html