[PyQt5][原创]菜单栏的使用
# QMenuBar/QMenu/QAction的使用(菜单栏) from PyQt5.QtWidgets import * from PyQt5.QtCore import QDir from PyQt5.QtGui import QIcon, QPixmap, QFont from PyQt5.QtCore import QDate import sys class MainForm(QMainWindow): def __init__(self, parent=None): super(MainForm, self).__init__(parent) self.setFixedSize(500, 500) self.layout = QHBoxLayout() self.menubar = self.menuBar() # 获取窗体的菜单栏 self.file = self.menubar.addMenu("菜单") self.file.addAction("新建") self.save = QAction("保存", self) self.save.setShortcut("Ctrl+S") # 设置快捷键 self.file.addAction(self.save) self.edit = self.file.addMenu("方向") self.edit