本文整理汇总了Python中PyQt5.QtGui.QMenu方法的典型用法代码示例。如果您正苦于以下问题:Python QtGui.QMenu方法的具体用法?Python QtGui.QMenu怎么用?Python QtGui.QMenu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui
的用法示例。
在下文中一共展示了QtGui.QMenu方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onListImageFilesContextMenuRequested
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QMenu [as 别名]
def onListImageFilesContextMenuRequested(self, point):
current_item = self.ui.listWidgetImageFiles.currentItem()
if current_item is None:
return
pop_menu = QtGui.QMenu()
delete_action = QtGui.QAction(u'删除', self)
pop_menu.addAction(delete_action)
delete_action.triggered.connect(self.DeletePatternItem)
modify_action = QtGui.QAction(u'修改', self)
pop_menu.addAction(modify_action)
modify_action.triggered.connect(self.ModifyPatternItem)
cancel_modify_action = QtGui.QAction(u'取消修改', self)
pop_menu.addAction(cancel_modify_action)
cancel_modify_action.triggered.connect(self.CancelModifyPatternItem)
pop_menu.exec_(QtGui.QCursor.pos())
示例2: __init__
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QMenu [as 别名]
def __init__(self, sandbox, *args, **kwargs):
QtWidgets.QMenu.__init__(self)
self.setTitle('Add Source')
self.sandbox = sandbox
backends = set(src.display_backend for src in __sources__)
for ibe, be in enumerate(backends):
self.addSection(be)
for src in [s for s in __sources__
if s.display_backend == be]:
self.addSourceDelegate(src)
if ibe is not len(backends) - 1:
self.addSeparator()
示例3: _setup_menu
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QMenu [as 别名]
def _setup_menu(self):
""" Sets up the main menu.
"""
# file_menu = self.menuBar().addMenu("&File")
self.menu = QtGui.QMenu(self)
self.menu.addAction("C&lose", self.close_window, "Ctrl+W")
self.menu.addAction("E&xit", self.quit_application, "Ctrl+Q")
if DEBUGGING is True:
self.menu.addSeparator()
self.menu.addAction("&Test", self.my_test, "Ctrl+T")
self.show_cols_submenu = self.menu.addMenu("Table columns")
self.menu.addAction(self.toggle_callable_action)
self.menu.addAction(self.toggle_special_attribute_action)
self.titleBar().settingDownButton.setMenu(self.menu)
self.titleBar().settingMenuShowed.connect(
self.titleBar().settingDownButton.showMenu)
示例4: classifier
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QMenu [as 别名]
def classifier(parent):
main_menu = parent.menuBar()
# classifier menu
parent.trainfiles = []
parent.statlabels = None
parent.loadMenu = QtGui.QMenu("Load", parent)
parent.loadClass = QtGui.QAction("from file", parent)
parent.loadClass.triggered.connect(lambda: classgui.load_classifier(parent))
parent.loadClass.setEnabled(False)
parent.loadMenu.addAction(parent.loadClass)
parent.loadUClass = QtGui.QAction("default classifier", parent)
parent.loadUClass.triggered.connect(lambda: classgui.load_default_classifier(parent))
parent.loadUClass.setEnabled(False)
parent.loadMenu.addAction(parent.loadUClass)
parent.loadSClass = QtGui.QAction("built-in classifier", parent)
parent.loadSClass.triggered.connect(lambda: classgui.load_s2p_classifier(parent))
parent.loadSClass.setEnabled(False)
parent.loadMenu.addAction(parent.loadSClass)
parent.loadTrain = QtGui.QAction("Build", parent)
parent.loadTrain.triggered.connect(lambda: classgui.load_list(parent))
parent.loadTrain.setEnabled(False)
parent.saveDefault = QtGui.QAction("Save loaded as default", parent)
parent.saveDefault.triggered.connect(lambda: classgui.class_default(parent))
parent.saveDefault.setEnabled(False)
parent.resetDefault = QtGui.QAction("Reset default to built-in", parent)
parent.resetDefault.triggered.connect(lambda: classgui.reset_default(parent))
parent.resetDefault.setEnabled(True)
class_menu = main_menu.addMenu("&Classifier")
class_menu.addMenu(parent.loadMenu)
class_menu.addAction(parent.loadTrain)
class_menu.addAction(parent.resetDefault)
class_menu.addAction(parent.saveDefault)