📜  pyqt 菜单栏示例 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:45.072000             🧑  作者: Mango

代码示例1
menubar = self.menuBar() # create our menubar
file = menubar.addMenu("&File") # create a file menu
open = QAction("&Open", self) # create a QAction
open.setShortcut("Ctrl+O") # set a shortcut for it
file.addAction(open) # and add it to our menu

# create another one and add it again to our menu
save = QAction("&Save",self) 
save.setShortcut("Ctrl+S")
file.addAction(save)

# and if you want to connect your QActions to your slots you can do it like:
open.triggered.connect(lambda: self.yourfunction())