PyQt5--MainWindow
程序员文章站
2022-06-24 14:32:14
1 # -*- coding:utf-8 -*- 2 ''' 3 Created on Sep 14, 2018 4 5 @author: SaShuangYiBing 6 ''' 7 import sys 8 from PyQt5.QtWidgets import QApplication,QMa... ......
1 # -*- coding:utf-8 -*- 2 ''' 3 created on sep 14, 2018 4 5 @author: sashuangyibing 6 ''' 7 import sys 8 from pyqt5.qtwidgets import qapplication,qmainwindow,qtextedit,qaction 9 from pyqt5.qtgui import qicon 10 11 class new_test(qmainwindow): 12 def __init__(self): 13 super().__init__() 14 self.initui() 15 16 def initui(self): 17 textedit = qtextedit() 18 self.setcentralwidget(textedit) 19 20 exitaction = qaction(qicon('tools.png'),'exit',self) 21 exitaction.setshortcut('ctrl+q') 22 exitaction.triggered.connect(self.close) 23 24 self.statusbar() 25 26 menubar = self.menubar() 27 filemenu = menubar.addmenu('&file') 28 filemenu.addaction(exitaction) 29 30 toolbar = self.addtoolbar('exit') 31 toolbar.addaction(exitaction) 32 33 self.setgeometry(300,300,250,150) 34 self.setwindowtitle('main window') 35 self.show() 36 37 if __name__ == "__main__": 38 app = qapplication(sys.argv) 39 ex = new_test() 40 sys.exit(app.exec_())