Python PyQt5.QtWidgets.QMenu() Examples

The following are 30 code examples of PyQt5.QtWidgets.QMenu(). 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 also want to check out all available functions/classes of the module PyQt5.QtWidgets , or try the search function .
Example #1
Source File: angrysearch.py    From ANGRYsearch with GNU General Public License v2.0 8 votes vote down vote up
def contextMenuEvent(self, event):
        right_click_menu = Qw.QMenu(self)

        act_open = right_click_menu.addAction('Open')
        act_open.triggered.connect(self.parent().parent().right_clk_open)

        act_open_path = right_click_menu.addAction('Open Path')
        act_open_path.triggered.connect(self.parent().parent().right_clk_path)

        right_click_menu.addSeparator()

        act_copy_path = right_click_menu.addAction('Copy Path')
        act_copy_path.triggered.connect(self.parent().parent().right_clk_copy)

        right_click_menu.exec_(event.globalPos())


# THE PRIMARY GUI DEFINING INTERFACE WIDGET, THE WIDGET WITHIN THE MAINWINDOW 
Example #2
Source File: first.py    From FIRST-plugin-ida with GNU General Public License v2.0 7 votes vote down vote up
def custom_menu(self, point):
            index = self.tree_view.indexAt(point)
            address = index.data(FIRSTUI.ROLE_ADDRESS)
            if not address:
                return

            menu = QtWidgets.QMenu(self.tree_view)
            goto_action = QtWidgets.QAction('&Go to Function', self.tree_view)
            goto_action.triggered.connect(lambda:IDAW.Jump(address))
            menu.addAction(goto_action)

            metadata_id = index.data(FIRSTUI.ROLE_ID)
            if metadata_id:
                history_action = QtWidgets.QAction('View &History', self.tree_view)
                history_action.triggered.connect(lambda:self.metadata_history(metadata_id))
                menu.addAction(history_action)

            menu.exec_(QtGui.QCursor.pos()) 
Example #3
Source File: magic.py    From heap-viewer with GNU General Public License v3.0 6 votes vote down vote up
def context_menu(self, position):
        sender = self.sender()
        menu = QtWidgets.QMenu()
        
        copy_action = menu.addAction("Copy value")
        copy_row = menu.addAction("Copy row")
        view_chunk = menu.addAction("View chunk")
        jump_to = menu.addAction("Jump to chunk")

        chunk_addr = int(sender.item(sender.currentRow(), 3).text(), 16)
        action = menu.exec_(sender.mapToGlobal(position))
       
        if action == copy_action:
            sender.copy_selected_value()

        if action == copy_row:
            sender.copy_selected_row()

        elif action == jump_to:
            idc.jumpto(chunk_addr)

        elif action == view_chunk:
            self.parent.parent.show_chunk_info(chunk_addr) 
Example #4
Source File: cue_layout.py    From linux-show-player with GNU General Public License v3.0 6 votes vote down vote up
def show_cue_context_menu(self, position):
        menu = QMenu(self)

        cue_class = self.get_context_cue().__class__
        for item in self.cm_registry.filter(cue_class):
            if isinstance(item, QAction):
                menu.addAction(item)
            elif isinstance(item, QMenu):
                menu.addMenu(item)

        menu.move(position)
        menu.show()

        # Adjust the menu position
        desktop = qApp.desktop().availableGeometry()
        menu_rect = menu.geometry()

        if menu_rect.bottom() > desktop.bottom():
            menu.move(menu.x(), menu.y() - menu.height())
        if menu_rect.right() > desktop.right():
            menu.move(menu.x() - menu.width(), menu.y()) 
Example #5
Source File: synchronizer.py    From linux-show-player with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self):
        self.syncMenu = QMenu(translate('Synchronizer', 'Synchronization'))
        self.menu_action = MainWindow().menuTools.addMenu(self.syncMenu)

        self.addPeerAction = QAction(
            translate('Synchronizer', 'Manage connected peers'), MainWindow())
        self.addPeerAction.triggered.connect(self.manage_peers)
        self.syncMenu.addAction(self.addPeerAction)

        self.showIpAction = QAction(
            translate('Synchronizer', 'Show your IP'), MainWindow())
        self.showIpAction.triggered.connect(self.show_ip)
        self.syncMenu.addAction(self.showIpAction)

        self.peers = []
        self.cue_media = {} 
Example #6
Source File: __init__.py    From pychemqt with GNU General Public License v3.0 6 votes vote down vote up
def _menuCalculate(self):
        """QMenu for table actions"""
        menu = QtWidgets.QMenu(QtWidgets.QApplication.translate(
            "pychemqt", "Calculate"), parent=self)
        saturationAction = createAction(
            QtWidgets.QApplication.translate("pychemqt", "Saturation"),
            slot=self.showSaturation, parent=self)
        menu.addAction(saturationAction)
        IsopropertyAction = createAction(
            QtWidgets.QApplication.translate("pychemqt", "Isoproperty"),
            slot=self.showIsoproperty, parent=self)
        menu.addAction(IsopropertyAction)
        menu.addSeparator()
        SpecifyAction = createAction(
            QtWidgets.QApplication.translate("pychemqt", "Specified point"),
            slot=self.addTableSpecified, parent=self)
        menu.addAction(SpecifyAction)
        return menu 
Example #7
Source File: first.py    From FIRST-plugin-ida with GNU General Public License v2.0 6 votes vote down vote up
def applied_custom_menu(self, point):
        index = self.applied_tree_view.indexAt(point)
        address = index.data(FIRSTUI.ROLE_ADDRESS)
        if not address:
            return

        menu = QtWidgets.QMenu(self.applied_tree_view)
        goto_action = QtWidgets.QAction('&Go to Function', self.applied_tree_view)
        goto_action.triggered.connect(lambda:IDAW.Jump(address))
        menu.addAction(goto_action)

        metadata_id = index.data(FIRSTUI.ROLE_ID)
        if metadata_id:
            history_action = QtWidgets.QAction('View &History', self.applied_tree_view)
            history_action.triggered.connect(lambda:self._metadata_history(metadata_id))
            menu.addAction(history_action)

        menu.exec_(QtGui.QCursor.pos()) 
Example #8
Source File: custom_widgets.py    From idasec with GNU Lesser General Public License v2.1 6 votes vote down vote up
def __init__(self, items, parent=None):
        super(ButtonLineEdit, self).__init__(parent)

        self.menu = QtWidgets.QMenu()
        for i in items:
          self.menu.addAction(i)

        self.button = QtWidgets.QToolButton(self)
        self.button.setStyleSheet('border: 0px; padding: 0px;')
        self.button.setCursor(QtCore.Qt.ArrowCursor)
        self.button.triggered.connect(self.menu_action_triggered)
        self.button.setPopupMode(QtWidgets.QToolButton.InstantPopup)
        self.button.setMenu(self.menu)

        frameWidth = self.style().pixelMetric(QtWidgets.QStyle.PM_DefaultFrameWidth)
        buttonSize = self.button.sizeHint()

        self.setAlignment(QtCore.Qt.Alignment(QtCore.Qt.AlignHCenter))
        self.setStyleSheet('QLineEdit {padding-right: %dpx; }' % (buttonSize.width() + frameWidth + 1))
        self.setMinimumSize(max(self.minimumSizeHint().width(), buttonSize.width() + frameWidth*2 + 2),
                            max(self.minimumSizeHint().height(), buttonSize.height() + frameWidth*2 + 2))
        self.setMaximumWidth(100) 
Example #9
Source File: table.py    From pychemqt with GNU General Public License v3.0 6 votes vote down vote up
def contextMenuEvent(self, event):
        """Show context menu over cell"""
        menu = QtWidgets.QMenu()
        actionCopy = createAction(
            QtWidgets.QApplication.translate("pychemqt", "&Copy"),
            slot=partial(self.copy, event), shortcut=QtGui.QKeySequence.Copy,
            icon=os.environ["pychemqt"] +
            os.path.join("images", "button", "editCopy"),
            parent=self)
        export = createAction(
            QtWidgets.QApplication.translate("pychemqt", "E&xport to csv"),
            self.exportCSV,
            icon=os.environ["pychemqt"] +
            os.path.join("images", "button", "export"),
            tip=QtWidgets.QApplication.translate(
                "pychemqt", "Export table to file"),
            parent=self)
        menu.addAction(actionCopy)
        menu.addSeparator()
        menu.addAction(export)
        menu.exec_(event.globalPos()) 
Example #10
Source File: replay_gain.py    From linux-show-player with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self):
        self._gain_thread = None

        # Entry in mainWindow menu
        self.menu = QMenu(translate('ReplayGain',
                                    'ReplayGain / Normalization'))
        self.menu_action = MainWindow().menuTools.addMenu(self.menu)

        self.actionGain = QAction(MainWindow())
        self.actionGain.triggered.connect(self.gain)
        self.actionGain.setText(translate('ReplayGain', 'Calculate'))
        self.menu.addAction(self.actionGain)

        self.actionReset = QAction(MainWindow())
        self.actionReset.triggered.connect(self._reset_all)
        self.actionReset.setText(translate('ReplayGain', 'Reset all'))
        self.menu.addAction(self.actionReset)

        self.actionResetSelected = QAction(MainWindow())
        self.actionResetSelected.triggered.connect(self._reset_selected)
        self.actionResetSelected.setText(translate('ReplayGain',
                                                   'Reset selected'))
        self.menu.addAction(self.actionResetSelected) 
Example #11
Source File: common.py    From awesometts-anki-addon with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, target, text, sequence, parent):
        """
        Initializes the menu action and wires its 'triggered' event.

        If the specified parent is a QMenu, this new action will
        automatically be added to it.
        """
        # PyQt5 uses an odd behaviour for multi-inheritance super() calls,
        # please see: http://pyqt.sourceforge.net/Docs/PyQt5/multiinheritance.html
        # Importantly there is no way to pass self.triggered to _Connector
        # before initialization of the QAction (and I do not know if it is
        # possible # to change order of initialization without changing the
        # order in mro). So one trick is to pass the signal it in a closure
        # so it will be kind of lazy evaluated later and the other option is to
        # pass only signal name and use getattr in _Connector. For now the latter
        # is used (more elegant, but less flexible).
        # Maybe composition would be more predictable here?
        super().__init__(ICON, text, parent, signal_name='triggered', target=target)

        self.setShortcut(sequence)
        self._sequence = sequence

        if isinstance(parent, QtWidgets.QMenu):
            parent.addAction(self) 
Example #12
Source File: CryptoIdentificationWidget.py    From grap with MIT License 6 votes vote down vote up
def _onSignatureTreeRightClicked(self, position):
        indexes = self.signature_tree.selectedIndexes()
        if len(indexes) > 0:
            level = 0
            index = indexes[0]
            while index.parent().isValid():
                index = index.parent()
                level += 1

        editAction = self.cc.QAction("Edit pattern", self)
        editAction.triggered.connect(self._onSignatureTreeEditPattern)
        self.addAction(editAction)
        
        printAction = self.cc.QAction("Print pattern path", self)
        printAction.triggered.connect(self._onSignatureTreePrintPatternPath)
        self.addAction(printAction)

        menu = QMenu()

        if level == 0:
            menu.addAction(editAction)
            menu.addAction(printAction)

        menu.exec_(self.signature_tree.viewport().mapToGlobal(position)) 
Example #13
Source File: magic.py    From heap-viewer with GNU General Public License v3.0 6 votes vote down vote up
def context_menu(self, position):
        sender = self.sender()

        menu = QtWidgets.QMenu()
        action_copy = menu.addAction("Copy value")
        action_copy_row = menu.addAction("Copy row")
        action_jump_to = menu.addAction("Jump to address")

        action = menu.exec_(sender.mapToGlobal(position))

        if action == action_copy:
            sender.copy_selected_value()

        elif action == action_copy_row:
            sender.copy_selected_row()

        elif action == action_jump_to:

            offset = int(sender.item(sender.currentRow(), 1).text(), 16)

            address = self.libc_base + offset
            idc.jumpto(address) 
Example #14
Source File: main.py    From PyQt5-Apps with GNU General Public License v3.0 6 votes vote down vote up
def downloadWidgetContext(self, point):
        """downloadWidget right click menu
        """
        popMenu = QMenu()
        startAThread = QAction('开始', self)
        pauseAThread = QAction('暂停', self)
        clearAThread = QAction('删除', self)

        startAThread.triggered.connect(lambda: self.operateAThread(1, point))
        pauseAThread.triggered.connect(lambda: self.operateAThread(2, point))
        clearAThread.triggered.connect(lambda: self.operateAThread(3, point))

        popMenu.addAction(startAThread)
        popMenu.addAction(pauseAThread)
        popMenu.addAction(clearAThread)

        popMenu.exec_(QCursor.pos()) 
Example #15
Source File: systray.py    From scudcloud with MIT License 6 votes vote down vote up
def __init__(self, window):
        super(Systray, self).__init__(QtGui.QIcon.fromTheme("scudcloud"), window)
        # When theme is not detect, let's force hicolor (Fixes #524)
        if QtGui.QIcon.themeName() == '':
            QtGui.QIcon.setThemeName('hicolor')
        self.activated.connect(self.activatedEvent)
        self.window = window
        self.setToolTip('ScudCloud')
        self.menu = QtWidgets.QMenu(self.window)
        self.menu.addAction('Show', self.restore)
        if scudcloud.scudcloud.Unity is None:
            self.menu.addAction('Toggle Menubar', self.toggleMenuBar)
        self.menu.addSeparator()
        self.menu.addAction(self.window.menus["file"]["preferences"])
        self.menu.addAction(self.window.menus["help"]["about"])
        self.menu.addSeparator()
        self.menu.addAction(self.window.menus["file"]["exit"])
        self.setContextMenu(self.menu) 
Example #16
Source File: system_tray_icon.py    From attack_monitor with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, icon, parent, main_app, learning_mode):
        self.main_app = main_app
        QtWidgets.QSystemTrayIcon.__init__(self, parent)
        self.setIcon(icon)
        menu = QtWidgets.QMenu(parent)

        #LEARNING MODE
        menu_learning_action = menu.addAction("Learning mode")
        menu_learning_action.setCheckable(True)
        menu_learning_action.setChecked(learning_mode)

        menu_learning_action.toggled.connect(self.main_app.set_learning_mode)

        menu.addSeparator()

        #EXIT
        exitAction = menu.addAction("Exit")
        exitAction.triggered.connect(self.exit_zero)

        self.setContextMenu(menu) 
Example #17
Source File: gui.py    From chinese-support-redux with GNU General Public License v3.0 6 votes vote down vote up
def add_menu(path):
    if not hasattr(mw, 'custom_menus'):
        mw.custom_menus = {}

    if len(path.split('::')) == 2:
        parent_path, child_path = path.split('::')
        has_child = True
    else:
        parent_path = path
        has_child = False

    if parent_path not in mw.custom_menus:
        parent = QMenu('&' + parent_path, mw)
        mw.custom_menus[parent_path] = parent
        mw.form.menubar.insertMenu(mw.form.menuTools.menuAction(), parent)

    if has_child and (path not in mw.custom_menus):
        child = QMenu('&' + child_path, mw)
        mw.custom_menus[path] = child
        mw.custom_menus[parent_path].addMenu(child) 
Example #18
Source File: optionwidgets.py    From kawaii-player with GNU General Public License v3.0 6 votes vote down vote up
def contextMenuEvent(self, event):
        menu = QtWidgets.QMenu(self)
        hd = menu.addAction("Hide Search Table")
        sideBar = menu.addAction("Show Sidebar")
        history = menu.addAction("Show History")
        action = menu.exec_(self.mapToGlobal(event.pos()))
        if action == hd:
            self.hide()
        elif action == sideBar:
            if ui.dockWidget_3.isHidden():
                ui.dockWidget_3.show()
                ui.btn1.setFocus()
            else:
                ui.dockWidget_3.hide()
                ui.list1.setFocus()
        elif action == history:
            ui.setPreOpt() 
Example #19
Source File: refnodesets_widget.py    From opcua-modeler with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, view):
        QObject.__init__(self, view)
        self.view = view
        self.model = QStandardItemModel()
        self.view.setModel(self.model)
        self.nodesets = []
        self.server_mgr = None
        self.view.header().setSectionResizeMode(1)
        
        addNodeSetAction = QAction("Add Reference Node Set", self.model)
        addNodeSetAction.triggered.connect(self.add_nodeset)
        self.removeNodeSetAction = QAction("Remove Reference Node Set", self.model)
        self.removeNodeSetAction.triggered.connect(self.remove_nodeset)

        self.view.setContextMenuPolicy(Qt.CustomContextMenu)
        self.view.customContextMenuRequested.connect(self.showContextMenu)
        self._contextMenu = QMenu()
        self._contextMenu.addAction(addNodeSetAction)
        self._contextMenu.addAction(self.removeNodeSetAction) 
Example #20
Source File: namespace_widget.py    From opcua-modeler with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, view):
        QObject.__init__(self, view)
        self.view = view
        self.model = QStandardItemModel()
        self.view.setModel(self.model)
        delegate = MyDelegate(self.view, self)
        delegate.error.connect(self.error.emit)
        self.view.setItemDelegate(delegate)
        self.node = None
        self.view.header().setSectionResizeMode(1)
        
        self.addNamespaceAction = QAction("Add Namespace", self.model)
        self.addNamespaceAction.triggered.connect(self.add_namespace)
        self.removeNamespaceAction = QAction("Remove Namespace", self.model)
        self.removeNamespaceAction.triggered.connect(self.remove_namespace)

        self.view.setContextMenuPolicy(Qt.CustomContextMenu)
        self.view.customContextMenuRequested.connect(self.showContextMenu)
        self._contextMenu = QMenu()
        self._contextMenu.addAction(self.addNamespaceAction)
        self._contextMenu.addAction(self.removeNamespaceAction) 
Example #21
Source File: uamodeler.py    From opcua-modeler with GNU General Public License v3.0 6 votes vote down vote up
def setup_context_menu_tree(self):
        self.ui.treeView.setContextMenuPolicy(Qt.CustomContextMenu)
        self.ui.treeView.customContextMenuRequested.connect(self._show_context_menu_tree)
        self._contextMenu = QMenu()

        # tree view menu
        self._contextMenu.addAction(self.ui.actionCopy)
        self._contextMenu.addAction(self.ui.actionPaste)
        self._contextMenu.addAction(self.ui.actionDelete)
        self._contextMenu.addSeparator()
        self._contextMenu.addAction(self.tree_ui.actionReload)
        self._contextMenu.addSeparator()
        self._contextMenu.addAction(self.ui.actionAddFolder)
        self._contextMenu.addAction(self.ui.actionAddObject)
        self._contextMenu.addAction(self.ui.actionAddVariable)
        self._contextMenu.addAction(self.ui.actionAddProperty)
        self._contextMenu.addAction(self.ui.actionAddMethod)
        self._contextMenu.addAction(self.ui.actionAddObjectType)
        self._contextMenu.addAction(self.ui.actionAddVariableType)
        self._contextMenu.addAction(self.ui.actionAddDataType) 
Example #22
Source File: sources_dock.py    From kite with 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 #23
Source File: sources_dock.py    From kite with 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 #24
Source File: inventorymodel.py    From PyPipboyApp with GNU General Public License v3.0 6 votes vote down vote up
def showItemContextMenu(self, datamanager, item, selected, pos, view):
        menu = QtWidgets.QMenu(view)
        actionCount = 0
        if self._cmIsUseActionEnabled(item, selected):
            actionCount += 1
            def _useItem():
                for item in selected:
                    datamanager.rpcUseItem(item)
                    time.sleep(0.1)
            uaction = menu.addAction(self._cmUseActionText(item, selected))
            uaction.triggered.connect(_useItem)
        if self._cmIsDropActionEnabled(item, selected):
            actionCount += 1
            def _dropItem():
                for item in selected:
                    datamanager.rpcDropItem(item, 1)
                    time.sleep(0.1)
            daction = menu.addAction(self._cmDropActionText(item, selected))
            daction.triggered.connect(_dropItem)
        if actionCount > 0:
            menu.exec(view.mapToGlobal(pos)) 
Example #25
Source File: marker.py    From PyPipboyApp with GNU General Public License v3.0 6 votes vote down vote up
def _markerContextMenuEvent_(self, event):
        menu = QtWidgets.QMenu(self.view)
        self._fillMarkerContextMenu_(event, menu)
        if self.labelItem and not self.labelAlwaysVisible:
            @QtCore.pyqtSlot(bool)
            def _toggleStickyLabel(value):
                if self.uid != None:
                    settingPath = 'globalmapwidget/stickylabels2/'
                    if (value):
                        self.widget._app.settings.setValue(settingPath+self.uid, int(value))
                    else:
                        self.widget._app.settings.beginGroup(settingPath);
                        self.widget._app.settings.remove(self.uid); 
                        self.widget._app.settings.endGroup();
                self.setStickyLabel(value)
            ftaction = menu.addAction('Sticky Label')
            ftaction.toggled.connect(_toggleStickyLabel)
            ftaction.setCheckable(True)
            ftaction.setChecked(self.stickyLabel)
        menu.exec(event.screenPos()) 
Example #26
Source File: table.py    From pychemqt with GNU General Public License v3.0 5 votes vote down vote up
def vHeaderClicked(self, position):
        """Show dialog to manage item in table"""
        row = self.verticalHeader().logicalIndexAt(position)
        rows = []
        for item in self.selectedItems():
            if item.row() not in rows:
                rows.append(item.row())
        rows.sort(reverse=True)

        actionCopy = createAction(
            QtWidgets.QApplication.translate("pychemqt", "&Copy"),
            slot=self.copy, shortcut=QtGui.QKeySequence.Copy,
            icon=os.environ["pychemqt"] +
            os.path.join("images", "button", "editCopy"),
            parent=self)
        if not self.selectedItems():
            actionCopy.setEnabled(False)

        actionDelete = createAction(
            QtWidgets.QApplication.translate("pychemqt", "Delete Point"),
            icon=os.environ["pychemqt"]+"/images/button/editDelete",
            slot=partial(self.delete, rows), parent=self)
        if not rows:
            actionDelete.setEnabled(False)

        actionInsert = createAction(
            QtWidgets.QApplication.translate("pychemqt", "Insert Point"),
            icon=os.environ["pychemqt"]+"/images/button/add",
            slot=partial(self.add, row), parent=self)

        menu = QtWidgets.QMenu()
        menu.addAction(actionCopy)
        menu.addSeparator()
        menu.addAction(actionDelete)
        menu.addAction(actionInsert)
        menu.exec_(self.mapToGlobal(position)) 
Example #27
Source File: radiowidget.py    From PyPipboyApp with GNU General Public License v3.0 5 votes vote down vote up
def _slotTableContextMenu(self, pos):
        index = self.widget.radioView.selectionModel().currentIndex()
        if index.isValid():
            value = self.radioViewModel.getPipValue(self.sortProxyModel.mapToSource(index).row())
            if value:
                menu = QtWidgets.QMenu(self.widget.radioView)
                def _toggleRadio():
                    self.dataManager.rpcToggleRadioStation(value)
                taction = menu.addAction('Toggle Radio')
                taction.triggered.connect(_toggleRadio)
                menu.exec(self.widget.radioView.mapToGlobal(pos)) 
Example #28
Source File: locationbrowser.py    From PyPipboyApp with GNU General Public License v3.0 5 votes vote down vote up
def _slotLocationTableContextMenu(self, pos):
        index = self.widget.locationView.selectionModel().currentIndex()
        if index.isValid():
            value = self.locationViewModel.getPipValue(self.sortProxyModel.mapToSource(index).row())
            if value:
                menu = QtWidgets.QMenu(self.widget.locationView)
                def _showOnMap():
                    if not self.globalMap.isVisible():
                        self.globalMap.setVisible(True)
                    self.globalMap.raise_()
                    self.globalMap.iwcCenterOnLocation(value.pipId)
                action = menu.addAction('Show On Map')
                action.triggered.connect(_showOnMap)
                menu.exec(self.widget.locationView.mapToGlobal(pos)) 
Example #29
Source File: gui.py    From ripr with MIT License 5 votes vote down vote up
def contextMenuEvent(self, event):
            index = self.indexAt(event.pos())
            
            self.triggeredIndex = index
            menu = QtWidgets.QMenu()
            menu.addAction("Save to File", self._saveCode)
            menu.addAction("Map Address", self._addMmap)
            menu.exec_(event.globalPos()) 
Example #30
Source File: flujo.py    From pychemqt with GNU General Public License v3.0 5 votes vote down vote up
def contextMenu(self):
        ViewAction = createAction(QtWidgets.QApplication.translate("pychemqt", "View Properties"), slot=self.view,
                                  parent=self.scene())
        SolidDistributionAction = createAction(QtWidgets.QApplication.translate("pychemqt", "Solid Distribution Fit"),
                                               slot=self.solidFit, parent=self.scene())
        if self.corriente:
            if not self.corriente.solido:
                SolidDistributionAction.setEnabled(False)
        else:
            ViewAction.setEnabled(False)
            SolidDistributionAction.setEnabled(False)

        contextMenu = QtWidgets.QMenu("Stream %i" % self.id, self.scene().parent())
        contextMenu.setIcon(QtGui.QIcon(QtGui.QPixmap(os.environ["pychemqt"] + "/images/equipment/stream.png")))
        contextMenu.addAction(QtWidgets.QApplication.translate("pychemqt", "Copy from another project"),
                              self.copyFromProject)
        contextMenu.addAction(SolidDistributionAction)
        contextMenu.addAction(QtWidgets.QApplication.translate("pychemqt", "Edit"), self.mouseDoubleClickEvent)
        contextMenu.addAction(QtGui.QIcon(os.environ["pychemqt"] + "/images/button/editDelete.png"),
                              QtWidgets.QApplication.translate("pychemqt", "Delete"), self.delete)
        contextMenu.addSeparator()
        contextMenu.addAction(ViewAction)
        contextMenu.addAction(QtWidgets.QApplication.translate("pychemqt", "Export to spreadsheet"), self.exportExcel)
        contextMenu.addAction(QtWidgets.QApplication.translate("pychemqt", "Show/Hide Id Label"),
                              self.idLabelVisibility)
        contextMenu.addAction(QtWidgets.QApplication.translate("pychemqt", "Appearance"), self.format)
        return contextMenu