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://cdweb.net/article/gseiph.html