当前位置: 首页>>代码示例>>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;未经允许,请勿转载。