Python PyQt5.QtWidgets.QAction() Examples

The following are 30 code examples for showing how to use PyQt5.QtWidgets.QAction(). 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: dcc   Author: amimo   File: mainwindow.py    License: Apache License 2.0 6 votes vote down vote up
def __init__(self, bin_windows, parent=None):
        super(TabsWindow, self).__init__(parent)
        self.bin_windows = bin_windows
        self.setTabsClosable(True)
        self.tabCloseRequested.connect(self.tabCloseRequestedHandler)
        self.currentChanged.connect(self.currentTabChanged)

        self.closeAllTabs = QtWidgets.QAction(
            "Close all tabs",
            self,
            triggered=self.actioncloseAllTabs)
        self.closeOtherTabs = QtWidgets.QAction(
            "Close other tabs",
            self,
            triggered=self.actioncloseOtherTabs)
        self.closeLeftTabs = QtWidgets.QAction(
            "Close left tabs",
            self,
            triggered=self.actioncloseLeftTabs)
        self.closeRightTabs = QtWidgets.QAction(
            "Close right tabs",
            self,
            triggered=self.actioncloseRightTabs) 
Example 2
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 3
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 4
Project: DevilYuan   Author: moyuanz   File: DyMainWindow.py    License: MIT License 6 votes vote down vote up
def _initMenu(self):
        # 创建菜单
        menuBar = self.menuBar()
        
        # 添加菜单
        menu = menuBar.addMenu('配置')

        action = QAction('股票历史日线数据源...', self)
        action.triggered.connect(self._configStockHistDaysDataSource)
        menu.addAction(action)

        action = QAction('MongoDB...', self)
        action.triggered.connect(self._configMongoDb)
        menu.addAction(action)

        subMenu = menu.addMenu('实盘交易')
        action = QAction('微信...', self)
        action.triggered.connect(self._configWx)
        subMenu.addAction(action)

        action = QAction('账号...', self)
        action.triggered.connect(self._configAccount)
        subMenu.addAction(action) 
Example 5
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 6
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 7
Project: kite   Author: pyrocko   File: sources_dock.py    License: GNU General Public License v3.0 6 votes vote down vote up
def addSourceDelegate(self, src):

            def addSource():
                source = src.getRepresentedSource(self.sandbox)
                source.lat = self.sandbox.frame.llLat
                source.lon = self.sandbox.frame.llLon
                source.easting = self.sandbox.frame.Emeter[-1] / 2
                source.northing = self.sandbox.frame.Nmeter[-1] / 2
                source.depth = 4*km

                if source:
                    self.sandbox.addSource(source)

            action = QtWidgets.QAction(src.display_name, self)
            action.setToolTip('<span style="font-family: monospace;">'
                              '%s</span>' % src.__represents__)

            action.triggered.connect(addSource)
            self.addAction(action)
            return action 
Example 8
Project: QMusic   Author: dragondjf   File: dmenu.py    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
def creatAction(self, submenu, menuaction):
        if 'checkable' in menuaction:
            setattr(self,
                    '%sAction' % menuaction['trigger'],
                    QAction(
                        QIcon(QPixmap(menuaction['icon'])),
                        u'%s' % menuaction['name'],
                        self,
                        checkable=menuaction['checkable']))
        else:
            setattr(self, '%sAction' % menuaction['trigger'], QAction(
                QIcon(QPixmap(menuaction['icon'])),
                u'%s' % menuaction['name'],
                self, ))

        action = getattr(self, '%sAction' % menuaction['trigger'])
        action.setShortcut(QKeySequence(menuaction['shortcut']))
        submenu.addAction(action)
        self.qactions.update({menuaction['trigger']: action}) 
Example 9
Project: python-code   Author: ouening   File: youdao_translation.py    License: MIT License 6 votes vote down vote up
def initMenuBar(self):
        '''
        初始化菜单栏
        '''
        menubar = self.menuBar()
        #self.actionExit.triggered.connect(qApp.quit)    # 按下菜单栏的Exit按钮会退出程序
        #self.actionExit.setStatusTip("退出程序")         # 左下角状态提示
        #self.actionExit.setShortcut('Ctrl+Q')           # 添加快捷键
        exitAct = QAction(QIcon('exit.png'), 'Exit', self)
        exitAct.setShortcut('Ctrl+Q')
        exitAct.triggered.connect(qApp.quit)
        
        fileMenu = menubar.addMenu('&File')
        fileMenu.addAction(exitAct)
        
        fileMenu = menubar.addMenu('&Help') 
Example 10
Project: python-code   Author: ouening   File: baidu_translation.py    License: MIT License 6 votes vote down vote up
def initMenuBar(self):
        '''
        初始化菜单栏
        '''
        menubar = self.menuBar()
        #self.actionExit.triggered.connect(qApp.quit)    # 按下菜单栏的Exit按钮会退出程序
        #self.actionExit.setStatusTip("退出程序")         # 左下角状态提示
        #self.actionExit.setShortcut('Ctrl+Q')           # 添加快捷键
        exitAct = QAction(QIcon('exit.png'), 'Exit', self)
        exitAct.setShortcut('Ctrl+Q')
        exitAct.triggered.connect(qApp.quit)
        
        fileMenu = menubar.addMenu('&File')
        fileMenu.addAction(exitAct)
        
        fileMenu = menubar.addMenu('&Help') 
Example 11
Project: imperialism-remake   Author: Trilarion   File: qt.py    License: GNU General Public License v3.0 6 votes vote down vote up
def create_action(icon: QtGui.QIcon, text, parent: QtWidgets.QWidget, trigger_connection=None, toggle_connection=None,
                  checkable=False) -> QtWidgets.QAction:
    """
    Shortcut for creation of an action and wiring.

    trigger_connection is the slot if the triggered signal of the QAction is fired
    toggle_connection is the slot if the toggled signal of the QAction is fired

    :param icon:
    :param text:
    :param parent:
    :param trigger_connection:
    :param toggle_connection:
    :param checkable:
    :return: The action
    """
    action = QtWidgets.QAction(icon, text, parent)
    if trigger_connection is not None:
        action.triggered.connect(trigger_connection)
    if toggle_connection is not None:
        action.toggled.connect(toggle_connection)
    action.setCheckable(checkable)
    return action 
Example 12
Project: scudcloud   Author: raelgc   File: speller.py    License: MIT License 6 votes vote down vote up
def populateContextMenu(self, menu, element):
        word = self.getWord(element)
        if self.isMisspelled(word):
            suggests = self.suggest(word)
            count = Resources.SPELL_LIMIT
            if len(suggests) < count:
                count = len(suggests)
            boldFont = menu.font()
            boldFont.setBold(True)
            for i in range(0, count):
                if isinstance(suggests[i], bytes):
                    suggests[i] = suggests[i].decode('utf8')
                action = QAction(str(suggests[i]), self)
                action.triggered.connect(lambda:self.replaceWord(element, word))
                action.setData(suggests[i])
                action.setFont(boldFont)
                menu.addAction(action)
            if count == 0:
                menu.addAction(menu.tr("No suggestions")).setEnabled(False)
            menu.addSeparator(); 
Example 13
Project: CQ-editor   Author: CadQuery   File: cq_object_inspector.py    License: Apache License 2.0 6 votes vote down vote up
def  __init__(self,parent):
        
        super(CQObjectInspector,self).__init__(parent)
        self.setHeaderHidden(False)
        self.setRootIsDecorated(True)
        self.setContextMenuPolicy(Qt.ActionsContextMenu)
        self.setColumnCount(2)
        self.setHeaderLabels(['Type','Value'])
        
        self.root = self.invisibleRootItem()
        self.inspected_items = []
        
        self._toolbar_actions = \
            [QAction(icon('inspect'),'Inspect CQ object',self,\
                     toggled=self.inspect,checkable=True)]
        
        self.addActions(self._toolbar_actions) 
Example 14
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 15
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 16
Project: linux-show-player   Author: FrancescoCeruti   File: presets.py    License: GNU General Public License v3.0 6 votes vote down vote up
def __init__(self):
        super().__init__()

        if not os.path.exists(PRESETS_DIR):
            os.makedirs(PRESETS_DIR, exist_ok=True)

        # Entry in mainWindow menu
        self.manageAction = QAction(MainWindow())
        self.manageAction.triggered.connect(self.__edit_presets)
        self.manageAction.setText(translate('Presets', 'Presets'))

        self.menu_action = MainWindow().menuTools.addAction(self.manageAction)

        self.loadOnCueAction = QAction(None)
        self.loadOnCueAction.triggered.connect(self.__load_on_cue)
        self.loadOnCueAction.setText(translate('Presets', 'Load preset'))

        self.createFromCueAction = QAction(None)
        self.createFromCueAction.triggered.connect(self.__create_from_cue)
        self.createFromCueAction.setText(translate('Presets', 'Save as preset'))

        CueLayout.cm_registry.add_separator()
        CueLayout.cm_registry.add_item(self.loadOnCueAction)
        CueLayout.cm_registry.add_item(self.createFromCueAction)
        CueLayout.cm_registry.add_separator() 
Example 17
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 18
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 19
Project: DIE   Author: ynvb   File: BPView.py    License: MIT License 6 votes vote down vote up
def OnCreate(self, form):
        """
        Called when the view is created
        """
        self.bp_tree_widget = QtWidgets.QTreeWidget()
        self.bp_handler = BpHandler.get_bp_handler()
        self.die_icons = DIE.UI.Die_Icons.get_die_icons()

        # Get parent widget
        self.parent = self.FormToPyQtWidget(form)

        self._add_parser_data()

        toolbar = QtWidgets.QToolBar()
        action_refresh = QtWidgets.QAction(self.die_icons.icon_refresh, "Refresh", toolbar)
        action_refresh.triggered.connect(self.refresh)
        toolbar.addAction(action_refresh)


        layout = QtWidgets.QGridLayout()
        layout.addWidget(toolbar)
        layout.addWidget(self.bp_tree_widget)

        self.parent.setLayout(layout) 
Example 20
Project: pychemqt   Author: jjgomera   File: mainWindow.py    License: GNU General Public License v3.0 6 votes vote down vote up
def aboutToShow_MenuRecentFiles(self):
        self.menuRecentFiles.clear()
        recentFiles = []
        for fname in self.recentFiles:
            if fname not in self.filename and QtCore.QFile.exists(fname):
                recentFiles.append(fname)
        if recentFiles:
            self.menuRecentFiles.addSeparator()
            for i, fname in enumerate(recentFiles):
                action = QtWidgets.QAction("&%d %s" % (i + 1, fname), self)
                action.setData(QtCore.QVariant(fname))
                action.triggered.connect(self.loadFile)
                self.menuRecentFiles.addAction(action)
        self.menuRecentFiles.addSeparator()
        self.menuRecentFiles.addAction(
            QtGui.QIcon(IMAGE_PATH + "button/clear.png"),
            QtWidgets.QApplication.translate("pychemqt", "Clear"),
            self.clearRecentFiles)

# File Manipulation 
Example 21
Project: sparrow-wifi   Author: ghostop14   File: telemetry.py    License: GNU General Public License v3.0 6 votes vote down vote up
def createTable(self):
        # Set up location table
        self.locationTable = QTableWidget(self)
        self.locationTable.setColumnCount(8)
        self.locationTable.setGeometry(10, 10, self.geometry().width()/2-20, self.geometry().height()/2)
        self.locationTable.setShowGrid(True)
        self.locationTable.setHorizontalHeaderLabels(['macAddr','SSID', 'Strength', 'Timestamp','GPS', 'Latitude', 'Longitude', 'Altitude'])
        self.locationTable.resizeColumnsToContents()
        self.locationTable.setRowCount(0)
        self.locationTable.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch)
        
        self.ntRightClickMenu = QMenu(self)
        newAct = QAction('Copy', self)        
        newAct.setStatusTip('Copy data to clipboard')
        newAct.triggered.connect(self.onCopy)
        self.ntRightClickMenu.addAction(newAct)
        
        self.locationTable.setContextMenuPolicy(Qt.CustomContextMenu)
        self.locationTable.customContextMenuRequested.connect(self.showNTContextMenu) 
Example 22
Project: sparrow-wifi   Author: ghostop14   File: telemetry.py    License: GNU General Public License v3.0 6 votes vote down vote up
def createTable(self):
        # Set up location table
        self.locationTable = QTableWidget(self)
        self.locationTable.setColumnCount(10)
        self.locationTable.setGeometry(10, 10, self.geometry().width()/2-20, self.geometry().height()/2)
        self.locationTable.setShowGrid(True)
        self.locationTable.setHorizontalHeaderLabels(['macAddr','Name', 'RSSI', 'TX Power', 'Est Range (m)', 'Timestamp','GPS', 'Latitude', 'Longitude', 'Altitude'])
        self.locationTable.resizeColumnsToContents()
        self.locationTable.setRowCount(0)
        self.locationTable.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch)
        
        self.ntRightClickMenu = QMenu(self)
        newAct = QAction('Copy', self)        
        newAct.setStatusTip('Copy data to clipboard')
        newAct.triggered.connect(self.onCopy)
        self.ntRightClickMenu.addAction(newAct)
        
        self.locationTable.setContextMenuPolicy(Qt.CustomContextMenu)
        self.locationTable.customContextMenuRequested.connect(self.showNTContextMenu) 
Example 23
Project: Python-GUI-Programming-Cookbook-Third-Edition   Author: PacktPublishing   File: Designer_First_UI_Exit.py    License: MIT License 6 votes vote down vote up
def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(400, 300)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 400, 21))
        self.menubar.setObjectName("menubar")
        self.menuFile = QtWidgets.QMenu(self.menubar)
        self.menuFile.setObjectName("menuFile")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        self.actionNew = QtWidgets.QAction(MainWindow)
        self.actionNew.setObjectName("actionNew")
        self.actionExit = QtWidgets.QAction(MainWindow)
        self.actionExit.setObjectName("actionExit")
        self.menuFile.addAction(self.actionNew)
        self.menuFile.addAction(self.actionExit)
        self.menubar.addAction(self.menuFile.menuAction())

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow) 
Example 24
Project: Python-GUI-Programming-Cookbook-Third-Edition   Author: PacktPublishing   File: Designer_First_UI.py    License: MIT License 6 votes vote down vote up
def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(400, 300)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 400, 21))
        self.menubar.setObjectName("menubar")
        self.menuFile = QtWidgets.QMenu(self.menubar)
        self.menuFile.setObjectName("menuFile")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        self.actionNew = QtWidgets.QAction(MainWindow)
        self.actionNew.setObjectName("actionNew")
        self.menuFile.addAction(self.actionNew)
        self.menubar.addAction(self.menuFile.menuAction())

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow) 
Example 25
Project: pkmeter   Author: pkkid   File: pkwidgets.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _init_menu(self):
        self.addAction(QtWidgets.QAction('About PKMeter', self, triggered=self.pkmeter.about.show))
        self.addAction(QtWidgets.QAction('Preferences', self, triggered=self.pkmeter.config.show))
        self.addAction(QtWidgets.QAction('Quit', self, triggered=self.pkmeter.quit))
        self.setContextMenuPolicy(Qt.ActionsContextMenu) 
Example 26
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 27
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()) 
Example 28
Project: dcc   Author: amimo   File: treewindow.py    License: Apache License 2.0 5 votes vote down vote up
def createActions(self):
        self.xrefAct = QtWidgets.QAction(
            "Xref from/to",
            self,
            statusTip="List the references where this element is used",
            triggered=self.actionXref)
        self.expandAct = QtWidgets.QAction("Expand",
                                           self,
                                           statusTip="Expand all the subtrees",
                                           triggered=self.actionExpand)
        self.collapseAct = QtWidgets.QAction("Collapse",
                                             self,
                                             statusTip="Collapse all the subtrees",
                                             triggered=self.actionCollapse) 
Example 29
Project: qhangups   Author: xmikos   File: __main__.py    License: GNU General Public License v3.0 5 votes vote down vote up
def create_actions(self):
        """Create actions and connect relevant signals"""
        self.startAction = QtWidgets.QAction(self)
        self.startAction.triggered.connect(self.hangups_start)
        self.stopAction = QtWidgets.QAction(self)
        self.stopAction.triggered.connect(self.hangups_stop)
        self.settingsAction = QtWidgets.QAction(self)
        self.settingsAction.triggered.connect(self.settings)
        self.aboutAction = QtWidgets.QAction(self)
        self.aboutAction.triggered.connect(self.about)
        self.quitAction = QtWidgets.QAction(self)
        self.quitAction.triggered.connect(self.quit) 
Example 30
Project: Lector   Author: BasioMeusPuga   File: __main__.py    License: GNU General Public License v3.0 5 votes vote down vote up
def generate_library_filter_menu(self, directory_list=None):
        self.libraryFilterMenu.clear()

        def generate_name(path_data):
            this_filter = path_data[1]
            if not this_filter:
                this_filter = os.path.basename(
                    path_data[0]).title()
            return this_filter

        filter_actions = []
        filter_list = []
        if directory_list:
            checked = [i for i in directory_list if i[3] == QtCore.Qt.Checked]
            filter_list = list(map(generate_name, checked))
            filter_list.sort()

        filter_list.append(self._translate('Main_UI', 'Manually Added'))
        filter_actions = [QtWidgets.QAction(i, self.libraryFilterMenu) for i in filter_list]

        filter_all = QtWidgets.QAction('All', self.libraryFilterMenu)
        filter_actions.append(filter_all)

        for i in filter_actions:
            i.setCheckable(True)
            i.setChecked(True)
            i.triggered.connect(self.set_library_filter)

        self.libraryFilterMenu.addActions(filter_actions)
        self.libraryFilterMenu.insertSeparator(filter_all)
        self.libraryToolBar.libraryFilterButton.setMenu(self.libraryFilterMenu)