| 12345678910111213141516171819202122232425262728 |
- # Only needed for access to command line arguments
- import sys
- from PyQt5.QtCore import Qt
- from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel
- # 自定义窗口,继承 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_()
|