zoukankan      html  css  js  c++  java
  • 创建一个包括菜单栏,工具栏,状态栏,文本编辑部件的经典GUI应用程序的骨架

    效果如下:

    代码如下:

     1 #!/usr/bin/python3
     2 # -*- coding: utf-8 -*-
     3 
     4 """
     5 This program creates a skeleton of
     6 a classic GUI application with a menubar,
     7 toolbar, statusbar, and a central widget.
     8 
     9 """
    10 
    11 import sys
    12 from PyQt5.QtWidgets import QMainWindow, QTextEdit, QAction, QApplication
    13 from PyQt5.QtGui import QIcon
    14 
    15 
    16 class Example(QMainWindow):
    17 
    18     def __init__(self):
    19         super().__init__()
    20 
    21         self.initUI()
    22 
    23     def initUI(self):
    24 
    25         textEdit = QTextEdit()
    26         self.setCentralWidget(textEdit)
    27 
    28         exitAct = QAction(QIcon('picturesexit24.png'), 'Exit', self)
    29         exitAct.setShortcut('Ctrl+Q')
    30         exitAct.setStatusTip('Exit application')
    31         exitAct.triggered.connect(self.close)
    32 
    33         self.statusBar()
    34 
    35         menubar = self.menuBar()
    36         fileMenu = menubar.addMenu('&File')
    37         fileMenu.addAction(exitAct)
    38 
    39         toolbar = self.addToolBar('Exit')
    40         toolbar.addAction(exitAct)
    41 
    42         self.setGeometry(300, 300, 350, 250)
    43         self.setWindowTitle('Main window')
    44         self.show()
    45 
    46 
    47 if __name__ == '__main__':
    48 
    49     app = QApplication(sys.argv)
    50     ex = Example()
    51     sys.exit(app.exec_())
  • 相关阅读:
    python 中的[::-1]
    python 闭包
    elastic
    文件上传进度条修改
    python decorator的理解
    同方爬虫--面试题
    js typeof
    浅谈软件项目实施
    数独·唯一性技巧(Uniqueness)-1
    数独二
  • 原文地址:https://www.cnblogs.com/fuqia/p/8711151.html
Copyright © 2011-2022 走看看