Python PyQt5.QtWidgets.QMenu() Examples

The following are 30 code examples for showing how to use PyQt5.QtWidgets.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.QtWidgets , or try the search function .

Example 1
Project: ANGRYsearch   Author: DoTheEvo   File: angrysearch.py    License: GNU General Public License v2.0 6 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
Project: idasec   Author: RobinDavid   File: custom_widgets.py    License: 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 3
Project: qutebrowser   Author: qutebrowser   File: downloadview.py    License: GNU General Public License v3.0 6 votes vote down vote up
def show_context_menu(self, point):
        """Show the context menu."""
        index = self.indexAt(point)
        if index.isValid():
            item = self.model().data(index, downloads.ModelRole.item)
        else:
            item = None
        self._menu = QMenu(self)
        actions = self._get_menu_actions(item)
        for (name, handler) in actions:
            if name is None and handler is None:
                self._menu.addSeparator()
            else:
                assert name is not None
                assert handler is not None
                action = self._menu.addAction(name)
                action.triggered.connect(handler)
        if actions:
            self._menu.popup(self.viewport().mapToGlobal(point)) 
Example 4
Project: persepolis   Author: persepolisdm   File: mainwindow_ui.py    License: GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent):
        super().__init__()

        # set ui direction
        ui_direction = parent.persepolis_setting.value('ui_direction')

        if ui_direction == 'rtl':
            self.setLayoutDirection(Qt.RightToLeft)

        elif ui_direction in 'ltr':
            self.setLayoutDirection(Qt.LeftToRight)

        # creating context menu
        self.category_tree_menu = QMenu(self)

        # connecting activation  event
        self.activated.connect(parent.categoryTreeSelected)
        self.pressed.connect(parent.categoryTreeSelected) 
Example 5
Project: FIRST-plugin-ida   Author: vrtadmin   File: first.py    License: 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 6
Project: FIRST-plugin-ida   Author: vrtadmin   File: first.py    License: GNU General Public License v2.0 6 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 7
Project: chinese-support-redux   Author: luoliyan   File: gui.py    License: 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 8
Project: attack_monitor   Author: yarox24   File: system_tray_icon.py    License: 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 9
Project: opcua-modeler   Author: FreeOpcUa   File: refnodesets_widget.py    License: 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 10
Project: opcua-modeler   Author: FreeOpcUa   File: namespace_widget.py    License: 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 11
Project: opcua-modeler   Author: FreeOpcUa   File: uamodeler.py    License: 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 12
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 13
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 14
Project: kawaii-player   Author: kanishka-linux   File: optionwidgets.py    License: 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 15
Project: grap   Author: AirbusCyber   File: CryptoIdentificationWidget.py    License: 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 16
Project: PyPipboyApp   Author: matzman666   File: marker.py    License: 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 17
Project: PyPipboyApp   Author: matzman666   File: inventorymodel.py    License: 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 18
Project: scudcloud   Author: raelgc   File: systray.py    License: 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 19
Project: PyQt5-Apps   Author: taseikyo   File: main.py    License: 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 20
Project: heap-viewer   Author: danigargu   File: magic.py    License: 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 21
Project: heap-viewer   Author: danigargu   File: magic.py    License: 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 22
Project: awesometts-anki-addon   Author: AwesomeTTS   File: common.py    License: 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 23
Project: linux-show-player   Author: FrancescoCeruti   File: replay_gain.py    License: 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 24
Project: linux-show-player   Author: FrancescoCeruti   File: cue_layout.py    License: 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 25
Project: linux-show-player   Author: FrancescoCeruti   File: synchronizer.py    License: 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 26
Project: pychemqt   Author: jjgomera   File: __init__.py    License: 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 27
Project: pychemqt   Author: jjgomera   File: table.py    License: 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 28
Project: ANGRYsearch   Author: DoTheEvo   File: angrysearch.py    License: GNU General Public License v2.0 5 votes vote down vote up
def make_sys_tray(self):
        if Qw.QSystemTrayIcon.isSystemTrayAvailable():
            menu = Qw.QMenu()
            menu.addAction('v1.0.1')
            menu.addSeparator()
            exitAction = menu.addAction('Quit')
            exitAction.triggered.connect(self.close)

            self.tray_icon = Qw.QSystemTrayIcon()
            self.tray_icon.setIcon(self.icon)
            self.tray_icon.setContextMenu(menu)
            self.tray_icon.show()
            self.tray_icon.setToolTip('ANGRYsearch')
            self.tray_icon.activated.connect(self.sys_tray_clicking) 
Example 29
Project: simnibs   Author: simnibs   File: main_gui.py    License: GNU General Public License v3.0 5 votes vote down vote up
def setRightClickMenu (self):
        self.menu = QtWidgets.QMenu(self)
        self.copyAction = QtWidgets.QAction('Copy', self)
        self.copyAction.triggered.connect(self.copyElectrode)

        self.pasteAction = QtWidgets.QAction('Paste', self)
        self.pasteAction.triggered.connect(self.pasteElectrode)
        self.pasteAction.setEnabled(False)

        self.deleteAction = QtWidgets.QAction('Delete', self)
        self.deleteAction.triggered.connect(self.deleteElectrode)

        self.menu.addAction(self.copyAction)
        self.menu.addAction(self.pasteAction)
        self.menu.addAction(self.deleteAction) 
Example 30
Project: dcc   Author: amimo   File: sourcewindow.py    License: Apache License 2.0 5 votes vote down vote up
def CustomContextMenuHandler(self, pos):
        menu = QtWidgets.QMenu(self)
        menu.addAction(QtWidgets.QAction(
            "Xref ...",
            self,
            statusTip="List the references where this element is used",
            triggered=self.actionXref))
        menu.addAction(QtWidgets.QAction("&Goto",
                                         self,
                                         statusTip="Go to element definition",
                                         triggered=self.actionGoto))
        menu.addAction(
            QtWidgets.QAction("Rename...",
                              self,
                              statusTip="Rename an element (class, method, ...)",
                              triggered=self.actionRename))
        menu.addAction(QtWidgets.QAction(
            "&Info",
            self,
            statusTip=
            "Display info of an element (anything useful in the document)",
            triggered=self.actionInfo))
        menu.addAction(QtWidgets.QAction(
            "&Reload sources",
            self,
            statusTip=
            "Reload sources (needed when renaming changed other tabs)",
            triggered=self.reload_java_sources))
        menu.addAction(QtWidgets.QAction("&Copy",
                                         self,
                                         shortcut=QtGui.QKeySequence.Copy,
                                         statusTip="Copy the current selection's contents to the clipboard",
                                         triggered=self.actionCopy))
        menu.exec_(QtGui.QCursor.pos())