工具栏
# coding: utf-8
import sys
from PyQt5.QtWidgets import qApp, QApplication, QMainWindow, QAction
from PyQt5.QtGui import QIcon
class Example(QMainWindow):
def __init__(self):
super(Example, self).__init__()
self.initUI()
def initUI(self):
exitAction = QAction(QIcon('exit.png'), 'exit', self)
exitAction.setShortcut('Ctrl+Q')
exitAction.setStatusTip('exit Application')
self.statusBar()
exitAction.triggered.connect(qApp.quit)
self.toolBar = self.addToolBar('exit')
self.toolBar.addAction(exitAction)
self.setGeometry(300,300,300,300)
self.setWindowTitle('Toolbar')
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())