PyQt5的菜单栏,工具栏,状态栏的合并

<pre style="font-family: 宋体; font-size: 12pt; background-color: rgb(255, 255, 255);"><pre name="code" class="python">import sysfrom PyQt5.QtWidgets import QApplication, QMainWindow, QAction, QTextEditfrom PyQt5.QtGui import QIconclass Example(QMainWindow):def __init__(self):super().__init__()self.initUI()def initUI(self):textEdit = QTextEdit()self.setCentralWidget(textEdit) #创建了一个文本编辑控件exitAction = QAction(QIcon("C:\\Users\\hengli\\Pictures\\CameraMan\\ss.jpg"), '&退出', self)exitAction.setShortcut('Ctrl+Q')#设置快捷键exitAction.setStatusTip('退出应用')exitAction.triggered.connect(self.close)self.statusBar()menubar = self.menuBar()fileMenu = menubar.addMenu('&文件')fileMenu.addAction(exitAction)toolbar = self.addToolBar('EXIT')toolbar.addAction(exitAction)self.setGeometry(300, 300, 300, 200)self.setWindowTitle('Main window')self.show()if __name__ == '__main__':app = QApplication(sys.argv)ex = Example()sys.exit((app.exec_()))

转载请注明作者与出处:王小涛_同學

,困难与折磨对于人来说,是一把打向坯料的锤,

PyQt5的菜单栏,工具栏,状态栏的合并

相关文章:

你感兴趣的文章:

标签云: