# -*- coding:utf-8 -*- import sys from PyQt5.QtWidgets import QApplication, # QApplication为创建程序基类 # QWidget 为创建窗口基类 if __name__ == "__main__": # 创建一个桌面应用程序类 app = QApplication(sys.argv) # 创建一个窗口 w = QWidget() # 设置窗口大小 w.resize(800, 400) # 移动窗口 w.move(300, 300) # 设置窗口标题 w.setWindowTitle('第一个程序') # 显示窗口 w.show() # 进入程序的主循环,并通过exit函数确保主循环安全结束 sys.exit(app.exec_())