创建主窗口
1 """创建主窗口""" 2 import sys 3 from PyQt5.QtWidgets import QMainWindow, QApplication 4 from PyQt5.QtGui import QIcon 5 6 class MainWindow(QMainWindow): 7 def __init__(self, parent=None): 8 super().__init__() 9 10 self.resize(400, 200) 11 self.status = self.statusBar() 12 # 状态栏提示信息为5秒 13 self.status.showMessage("这是状态栏提示", 5000) 14 self.setWindowTitle("PyQtMainWindow 例子") 15 16 if __name__ == '__main__': 17 app = QApplication(sys.argv) 18 # 设置图标 19 app.setWindowIcon(QIcon('chinaz16.png')) 20 form = MainWindow() 21 form.show() 22 sys.exit(app.exec_())
学以致用,知行合一