MyApp.py 690 B

12345678910111213141516171819202122232425262728
  1. # Only needed for access to command line arguments
  2. import sys
  3. from PyQt5.QtCore import Qt
  4. from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel
  5. # 自定义窗口,继承 QMainWindow
  6. class MainWindow(QMainWindow):
  7. def __init__(self, *args, **kwargs):
  8. super(MainWindow, self).__init__(*args, **kwargs)
  9. self.setWindowTitle("My Awesome App") # 标题
  10. label = QLabel("THIS IS AWESOME!!!")
  11. label.setAlignment(Qt.AlignCenter)
  12. self.setCentralWidget(label)
  13. if __name__ == '__main__':
  14. app = QApplication(sys.argv)
  15. window = MainWindow()
  16. window.show() # 默认下 windows 是隐藏的
  17. # 开启事件循环
  18. app.exec_()