Python PyQt5.QtGui.QMenu() Examples

The following are 5 code examples for showing how to use PyQt5.QtGui.QMenu(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module PyQt5.QtGui , or try the search function .

Example 1
Project: FAE   Author: salan668   File: FeatureExtractionForm.py    License: GNU General Public License v3.0 6 votes vote down vote up
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()) 
Example 2
Project: kite   Author: pyrocko   File: sources_dock.py    License: GNU General Public License v3.0 6 votes vote down vote up
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() 
Example 3
Project: kite   Author: pyrocko   File: sources_dock.py    License: GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent, idx, *args, **kwargs):
            QtGui.QMenu.__init__(self, *args, **kwargs)
            self.parent = parent
            self.sandbox = parent.sandbox
            self.idx = idx

            def removeSource():
                self.sandbox.sources.removeSource(self.idx)

            editAction = self.addAction(
                'Edit', lambda: self.parent.editSource(self.idx))

            self.addMenu(
                SourcesAddButton.SourcesAddMenu(self.sandbox, self))
            self.addSeparator()

            removeAction = self.addAction(
                self.style().standardIcon(
                    QtGui.QStyle.SP_DialogCloseButton),
                'Remove', removeSource)

            if self.sandbox.sources.rowCount(QtCore.QModelIndex()) == 0:
                editAction.setEnabled(False)
                removeAction.setEnabled(False) 
Example 4
Project: PFramer   Author: dragondjf   File: objectbrowser.py    License: GNU General Public License v3.0 6 votes vote down vote up
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) 
Example 5
Project: suite2p   Author: MouseLand   File: menus.py    License: GNU General Public License v3.0 5 votes vote down vote up
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)