PythonGui->菜单栏

来源:互联网 发布:淘宝企业开店 编辑:程序博客网 时间:2024/05/22 13:16
<span style="font-size:24px;">import sysfrom PyQt4 import QtGui, QtCoreclass MainWindow(QtGui.QMainWindow):    def __init__(self):        QtGui.QMainWindow.__init__(self)                self.resize(250, 150)        self.setWindowTitle('menubar')                exit = QtGui.QAction(QtGui.QIcon('icons/web.png'), 'Exit', self)<span style="color:#ff0000;">        exit.setShortcut('Ctrl+Q')        exit.setStatusTip('Exit application')        self.connect(exit, QtCore.SIGNAL('triggered()'), QtCore.SLOT('close()'))</span>                self.statusBar()        menubar = self.menuBar()<span style="color:#ff0000;">        file = menubar.addMenu('&File')        file.addAction(exit)</span>app = QtGui.QApplication(sys.argv)main = MainWindow()main.show()sys.exit(app.exec_())</span>

0 0