生活会辜负努力的人,但不会辜负一直努力的人

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

效果如下:

代码如下:

 1 #!/usr/bin/python3
 2 # -*- coding: utf-8 -*-
 3 
 4 """
 5 This program creates a toolbar.
 6 The toolbar has one action, which
 7 terminates the application, if triggered.
 8 
 9 """
10 
11 import sys
12 from PyQt5.QtWidgets import QMainWindow, QAction, qApp, 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         exitAct = QAction(QIcon('pictures\exit24.png'), 'Exit', self)
26         exitAct.setShortcut('Ctrl+Q')
27         exitAct.triggered.connect(qApp.quit)
28 
29         self.toolbar = self.addToolBar('Exit')
30         self.toolbar.addAction(exitAct)
31 
32         self.setGeometry(300, 300, 300, 200)
33         self.setWindowTitle('Toolbar')
34         self.show()
35 
36 
37 if __name__ == '__main__':
38 
39     app = QApplication(sys.argv)
40     ex = Example()
41     sys.exit(app.exec_())

 

posted on 2018-04-03 20:51  何许亻也  阅读(232)  评论(0)    收藏  举报