zoukankan      html  css  js  c++  java
  • pyqt5 工具栏文字图片同时显示

    import sys
    from PyQt5.QtWidgets import QMainWindow, QTextEdit, QAction, QApplication
    from PyQt5.QtGui import QIcon
    from PyQt5.QtCore import Qt
    
    class Example(QMainWindow):
    
        def __init__(self):
            super().__init__()
            self.initUI()
        def initUI(self):
            textEdit = QTextEdit()
            self.setCentralWidget(textEdit)
    
            exitAction = QAction(QIcon('images/exit.png'), 'Exit',self)
            exitAction.setShortcut('Ctrl+Q')
            exitAction.setStatusTip('Exit application')
            exitAction.triggered.connect(self.close)
    
            self.statusBar()
    
            menubar = self.menuBar()
            fileMenu = menubar.addMenu('&File')
            fileMenu.addAction(exitAction)
    
            toolbar = self.addToolBar('Exit')
            # toolbar.setToolButtonStyle(Qt.ToolButtonTextUnderIcon) # 文字图片垂直排列
            toolbar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)  # 文字图片水平排列
            toolbar.addAction(exitAction)
    
            self.setGeometry(300, 300, 350, 250)
            self.setWindowTitle('Main window')
    
            self.show()
    
    
    if __name__ == '__main__':
        app = QApplication(sys.argv)
        ex = Example()
        sys.exit(app.exec_())
  • 相关阅读:
    微信分享 apicloud方式 中遇到的坎
    css之颜色篇
    css总结
    记一些茅塞顿开的事情
    apicloud
    安装MySQL
    智能家居
    java
    数据库设计好不好,分配很重要。
    WP8.1的shell:SystemTray去哪了?
  • 原文地址:https://www.cnblogs.com/liugp/p/10432239.html
Copyright © 2011-2022 走看看