| 123456789101112131415161718192021222324252627 |
- # Only needed for access to command line arguments
- import sys
- from PyQt5.QtCore import *
- from PyQt5.QtWidgets import *
- # 自定义窗口,继承 QMainWindow
- class MainWindow(QMainWindow):
- def __init__(self, *args, **kwargs):
- super(MainWindow, self).__init__(*args, **kwargs)
- self.setWindowTitle("My Awesome App") # 标题
- label = QLabel("THIS IS AWESOME!!!")
- label.setAlignment(Qt.AlignCenter)
- self.setCentralWidget(label)
- if __name__ == '__main__':
- app = QApplication(sys.argv)
- window = MainWindow()
- window.show() # 默认下 windows 是隐藏的
- # 开启事件循环
- app.exec_()
|