对于学习Python人工智能的朋友来讲,不少知识点都没有接触过,须要一点点的去接触,观看视频等等,今天小猿圈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):人工智能
def __init__(self):cdn
super().__init__()视频
self.initUI()blog
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是一个能够持续发展的技术,不管是什么方向均可以有本身的一番做为,你有想过学习Python交流群:242719133,想学习Python能够到小猿圈去直接观看,小猿圈是全免费?恭喜你答对了,所有免费这里面从基础到实战的全部学习资料,能够知足你提高本身,为你实现编程梦想的起点。