今天千锋扣丁学堂Python培训老师给你们分享一篇关于pyqt5实现工具栏文字图片同时显示的详细介绍,但愿对同窗们学习Python开发有所帮助,下面咱们一块儿来看一下吧。微信
以下所示:app
import syside
from PyQt5.QtWidgets import QMainWindow, QTextEdit, QAction, QApplication工具
from PyQt5.QtGui import QIcon学习
from PyQt5.QtCore import Qtui
class Example(QMainWindow):code
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_())
以上就是关于千锋扣丁学堂Python培训之pyqt5实现工具栏文字图片同时显示的所有内容了,但愿能给你们一个参考,想要了解更多关于Python开发方面内容的小伙伴,请关注扣丁学堂Python培训官网、微信等平台,扣丁学堂IT职业在线学习教育有专业的Python讲师为您指导,此外扣丁学堂老师精心推出的Python视频教程定能让你快速掌握Python从入门到精通开发实战技能。