#2
xiangyue05102018-06-14 14:33
|
但是运行的时候,直接报错退出了。请教各位大神
Process finished with exit code -1073740791 (0xC0000409)
程序代码:
import sys
from PyQt5.QtWidgets import QMainWindow, QAction, qApp, QApplication
from PyQt5.QtGui import QIcon
class Example(QMainWindow):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.statusBar().showMessage('Ready') # 设置状态栏
# 设置一个退出的动作按钮
exitAction = QAction(QIcon('web.png'), '&Exit', self)
exitAction.setShortcut('Ctrl+Q')
exitAction.setStatusTip('Exit application')
exitAction.triggered.connect(qApp.quit)
aboutAction = QAction(QIcon('web.png'), '&About', self)
aboutAction.setStatusTip('About application')
aboutAction.triggered.connect(self.onAboutTriggered)
#创建一个菜单栏
menubar = self.menuBar()
#添加菜单
fileMenu = menubar.addMenu('&File')
#添加事件(菜单按钮),与前面定义好的动作按钮对应
fileMenu.addAction(exitAction)
aboutMenu= menubar.addMenu('&About')
aboutMenu.addAction(aboutAction)
# 创建工作栏,并与前面定义好的动作按钮对应
self.toolbar = self.addToolBar('Exit')
self.toolbar.addAction(exitAction)
self.toolbar = self.addToolBar('Help')
self.toolbar.addAction(aboutAction)
self.setGeometry(300, 300, 300, 200)
self.setWindowTitle('Menubar')
self.show()
def onAboutTriggered(self):
QMessageBox.about(self, "About", "About this application")
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())