當前位置: 首頁>>代碼示例>>Python>>正文


Python QtWidgets.QAction方法代碼示例

本文整理匯總了Python中PyQt5.QtWidgets.QAction方法的典型用法代碼示例。如果您正苦於以下問題:Python QtWidgets.QAction方法的具體用法?Python QtWidgets.QAction怎麽用?Python QtWidgets.QAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt5.QtWidgets的用法示例。


在下文中一共展示了QtWidgets.QAction方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: applied_custom_menu

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QAction [as 別名]
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()) 
開發者ID:vrtadmin,項目名稱:FIRST-plugin-ida,代碼行數:20,代碼來源:first.py

示例2: __init__

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QAction [as 別名]
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) 
開發者ID:amimo,項目名稱:dcc,代碼行數:25,代碼來源:mainwindow.py

示例3: custom_menu

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QAction [as 別名]
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()) 
開發者ID:vrtadmin,項目名稱:FIRST-plugin-ida,代碼行數:20,代碼來源:first.py

示例4: _initMenu

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QAction [as 別名]
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) 
開發者ID:moyuanz,項目名稱:DevilYuan,代碼行數:25,代碼來源:DyMainWindow.py

示例5: __init__

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QAction [as 別名]
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) 
開發者ID:FreeOpcUa,項目名稱:opcua-modeler,代碼行數:21,代碼來源:refnodesets_widget.py

示例6: __init__

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QAction [as 別名]
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) 
開發者ID:FreeOpcUa,項目名稱:opcua-modeler,代碼行數:23,代碼來源:namespace_widget.py

示例7: addSourceDelegate

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QAction [as 別名]
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 
開發者ID:pyrocko,項目名稱:kite,代碼行數:22,代碼來源:sources_dock.py

示例8: creatAction

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QAction [as 別名]
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}) 
開發者ID:dragondjf,項目名稱:QMusic,代碼行數:21,代碼來源:dmenu.py

示例9: initMenuBar

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QAction [as 別名]
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') 
開發者ID:ouening,項目名稱:python-code,代碼行數:18,代碼來源:youdao_translation.py

示例10: create_action

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QAction [as 別名]
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 
開發者ID:Trilarion,項目名稱:imperialism-remake,代碼行數:25,代碼來源:qt.py

示例11: populateContextMenu

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QAction [as 別名]
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(); 
開發者ID:raelgc,項目名稱:scudcloud,代碼行數:22,代碼來源:speller.py

示例12: __init__

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QAction [as 別名]
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) 
開發者ID:CadQuery,項目名稱:CQ-editor,代碼行數:19,代碼來源:cq_object_inspector.py

示例13: downloadWidgetContext

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QAction [as 別名]
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()) 
開發者ID:taseikyo,項目名稱:PyQt5-Apps,代碼行數:19,代碼來源:main.py

示例14: __init__

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QAction [as 別名]
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) 
開發者ID:AwesomeTTS,項目名稱:awesometts-anki-addon,代碼行數:26,代碼來源:common.py

示例15: __init__

# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QAction [as 別名]
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() 
開發者ID:FrancescoCeruti,項目名稱:linux-show-player,代碼行數:27,代碼來源:presets.py


注:本文中的PyQt5.QtWidgets.QAction方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。