当前位置: 首页>>代码示例>>Python>>正文


Python QMenu.addAction方法代码示例

本文整理汇总了Python中PyQt4.QtGui.QMenu.addAction方法的典型用法代码示例。如果您正苦于以下问题:Python QMenu.addAction方法的具体用法?Python QMenu.addAction怎么用?Python QMenu.addAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtGui.QMenu的用法示例。


在下文中一共展示了QMenu.addAction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TrayIconUpdates

# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addAction [as 别名]
class TrayIconUpdates(QSystemTrayIcon):

    def __init__(self, parent):
        QSystemTrayIcon.__init__(self, parent)
        icon = QIcon(recursos.IMAGES['icon'])
        self.setIcon(icon)
        self.setup_menu()

    def setup_menu(self, show_downloads=False):
        self.menu = QMenu()

        #accion deshabilitar filtrado
        self.deshabilitarFiltradoAction = self.menu.addAction(
                            #self.style.standardIcon(QStyle.SP_DialogNoButton),
                            'Deshabilitar Filtrado'
                            )
        #accion habilitar filtrado
        self.habilitarFiltradoAction = self.menu.addAction(
                            #self.style.standardIcon(QStyle.SP_DialogYesButton),
                            'Habilitar Filtrado'
                            )
        self.habilitarFiltradoAction.setVisible(False)
        #cambiar password
        self.cambiarPasswordAction = self.menu.addAction(
                #self.style.standardIcon(QStyle.SP_BrowserReload),
                'Cambiar password de administrador'
                )
        #accion salir
        self.exitAction = self.menu.addAction(
                #self.style.standardIcon(QStyle.SP_TitleBarCloseButton),
                'Salir')
        self.setContextMenu(self.menu)
开发者ID:mboscovich,项目名称:Kerberus-Control-Parental,代码行数:34,代码来源:systemTray2.py

示例2: contextMenuEvent

# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addAction [as 别名]
    def contextMenuEvent(self, ev):
        index = self.indexAt(ev.pos())
        if not index.isValid():
            return

        if index != self.currentIndex():
            self.itemChanged(index)

        item = self.currentItem()

        menu = QMenu(self)

        if isinstance(item, (Table, Schema)):
            menu.addAction(self.tr("Rename"), self.rename)
            menu.addAction(self.tr("Delete"), self.delete)

            if isinstance(item, Table) and item.canBeAddedToCanvas():
                menu.addSeparator()
                menu.addAction(self.tr("Add to canvas"), self.addLayer)

        elif isinstance(item, DBPlugin):
            if item.database() is not None:
                menu.addAction(self.tr("Re-connect"), self.reconnect)
            menu.addAction(self.tr("Remove"), self.delete)

        elif not index.parent().isValid() and item.typeName() == "spatialite":
            menu.addAction(self.tr("New Connection..."), self.newConnection)

        if not menu.isEmpty():
            menu.exec_(ev.globalPos())

        menu.deleteLater()
开发者ID:redwoodxiao,项目名称:QGIS,代码行数:34,代码来源:db_tree.py

示例3: _menu_context_tree

# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addAction [as 别名]
    def _menu_context_tree(self, point):
        index = self.indexAt(point)
        if not index.isValid():
            return

        menu = QMenu(self)
        f_all = menu.addAction(self.tr("Fold all"))
        u_all = menu.addAction(self.tr("Unfold all"))
        menu.addSeparator()
        u_class = menu.addAction(self.tr("Unfold classes"))
        u_class_method = menu.addAction(self.tr("Unfold classes and methods"))
        u_class_attr = menu.addAction(self.tr("Unfold classes and attributes"))
        menu.addSeparator()
        #save_state = menu.addAction(self.tr("Save State"))

        self.connect(f_all, SIGNAL("triggered()"),
                     lambda: self.collapseAll())
        self.connect(u_all, SIGNAL("triggered()"),
                     lambda: self.expandAll())
        self.connect(u_class, SIGNAL("triggered()"), self._unfold_class)
        self.connect(u_class_method, SIGNAL("triggered()"),
                     self._unfold_class_method)
        self.connect(u_class_attr, SIGNAL("triggered()"),
                     self._unfold_class_attribute)
        #self.connect(save_state, SIGNAL("triggered()"),
            #self._save_symbols_state)

        menu.exec_(QCursor.pos())
开发者ID:AlexaProjects,项目名称:Alexa2,代码行数:30,代码来源:tree_symbols_widget.py

示例4: ScripterMenu

# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addAction [as 别名]
class ScripterMenu(QObject):
    """
    Scripter menu item in mainWindow menubar
    """

    def __init__(self, parent):
        QObject.__init__(self, parent)
        self.setObjectName("Menu")
        self.popup = QMenu(i18n("Scripter"))
        MenuHooks().insertMenuAfter("E&xtras", self.popup)
        self._load_entries()


    def _load_entries(self):
        for path in [scripter_path, os.path.expanduser("~/.scribus/scripter/")]:
            autoload_path = os.path.join(path, "autoload")
            if not os.path.exists(autoload_path):
                continue
            sys.path.insert(0, autoload_path)
            from scribusscript import load_scripts
            self.autoload_scripts = scripts = load_scripts(autoload_path)
            for sd in scripts:
                try:
                    sd.install()
                except:
                    excepthook.show_current_error(i18n("Error installing %r") % sd.name)


    def addAction(self, title, callback, *args):
        self.popup.addAction(title, callback, *args)


    def addSeparator(self):
        self.popup.addSeparator()
开发者ID:moceap,项目名称:scribus,代码行数:36,代码来源:init_scripter.py

示例5: handleEditorRightClick

# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addAction [as 别名]
    def handleEditorRightClick(self, position5d, globalWindowCoordinate):
        names = self.topLevelOperatorView.opCarving.doneObjectNamesForPosition(position5d[1:4])
       
        op = self.topLevelOperatorView.opCarving
        
        menu = QMenu(self)
        menu.addAction("position %d %d %d" % (position5d[1], position5d[2], position5d[3]))
        for name in names:
            menu.addAction("edit %s" % name)
            menu.addAction("delete %s" % name)
            if self.render:
                if name in self._shownObjects3D:
                    menu.addAction("remove %s from 3D view" % name)
                else:
                    menu.addAction("show 3D %s" % name)

        act = menu.exec_(globalWindowCoordinate)
        for name in names:
            if act is not None and act.text() == "edit %s" %name:
                op.loadObject(name)
            elif act is not None and act.text() =="delete %s" % name:
                op.deleteObject(name)
                if self.render and self._renderMgr.ready:
                    self._update_rendering()
            elif act is not None and act.text() == "show 3D %s" % name:
                label = self._renderMgr.addObject()
                self._shownObjects3D[name] = label
                self._update_rendering()
            elif act is not None and act.text() == "remove %s from 3D view" % name:
                label = self._shownObjects3D.pop(name)
                self._renderMgr.removeObject(label)
                self._update_rendering()
开发者ID:fblumenthal,项目名称:ilastik,代码行数:34,代码来源:carvingGui.py

示例6: menu_button

# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addAction [as 别名]
    def menu_button(self, main_action_id, ids, widget):
        '''
            Creates an :obj:`.OWButton` with a popup-menu and adds it to the parent ``widget``.
        '''
        id, name, attr_name, attr_value, callback, icon_name = self._expand_id(main_action_id)
        b = OWButton(parent=widget)
        m = QMenu(b)
        b.setMenu(m)
        b._actions = {}

        QObject.connect(m, SIGNAL("triggered(QAction*)"), b, SLOT("setDefaultAction(QAction*)"))

        if main_action_id:
            main_action = OWAction(self._plot, icon_name, attr_name, attr_value, callback, parent=b)
            QObject.connect(m, SIGNAL("triggered(QAction*)"), main_action, SLOT("trigger()"))

        for id in ids:
            id, name, attr_name, attr_value, callback, icon_name = self._expand_id(id)
            a = OWAction(self._plot, icon_name, attr_name, attr_value, callback, parent=m)
            m.addAction(a)
            b._actions[id] = a

        if m.actions():
            b.setDefaultAction(m.actions()[0])
        elif main_action_id:
            b.setDefaultAction(main_action)


        b.setPopupMode(QToolButton.MenuButtonPopup)
        b.setMinimumSize(40, 30)
        return b
开发者ID:Isilendil,项目名称:orange3,代码行数:33,代码来源:owplotgui.py

示例7: showSnippets

# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addAction [as 别名]
 def showSnippets(self, evt):
     popupmenu = QMenu()
     for name, snippet in self.snippets.iteritems():
         action = QAction(self.tr(name), self.btnSnippets)
         action.triggered[()].connect(lambda snippet=snippet: self.editor.insert(snippet))
         popupmenu.addAction(action)
     popupmenu.exec_(QCursor.pos())
开发者ID:Geoneer,项目名称:QGIS,代码行数:9,代码来源:ScriptEditorDialog.py

示例8: __init__

# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addAction [as 别名]
 def __init__(self, mwHandle):
     self.mw = mwHandle
     
     for x in xrange(2, 20):
         pin = eval("self.mw.pin%02d" % (x))
         menu = QMenu(pin)
         modeGroup = QActionGroup(self.mw)
         modeGroup.setExclusive(True)
         none = menu.addAction("&None")
         modeGroup.addAction(none)
         none.triggered.connect(self.clickNone)
         none.setCheckable(True)
         none.setChecked(True)
         input = menu.addAction("&Input")
         modeGroup.addAction(input)
         input.triggered.connect(self.clickInput)
         input.setCheckable(True)
         output = menu.addAction("&Output")
         modeGroup.addAction(output)
         output.triggered.connect(self.clickOutput)
         output.setCheckable(True)
         if self.mw.board.pins[x].PWM_CAPABLE:
             pwm = menu.addAction("&PWM")
             modeGroup.addAction(pwm)
             pwm.triggered.connect(self.clickPWM)
             pwm.setCheckable(True)
         if self.mw.board.pins[x].type == 2:
             analogic = menu.addAction(u"&Analógico")
             modeGroup.addAction(analogic)
             analogic.triggered.connect(self.clickAnalog)
             analogic.setCheckable(True)
         pin.setMenu(menu)
         pin.setStyleSheet("/* */") # force stylesheet update
开发者ID:GrandHsu,项目名称:Platex,代码行数:35,代码来源:mode.py

示例9: layercontextmenu

# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addAction [as 别名]
def layercontextmenu( layer, pos, parent=None, volumeEditor = None ):
    '''Show a context menu to manipulate properties of layer.

    layer -- a volumina layer instance
    pos -- QPoint 

    '''
    def onExport():
        
        if _has_lazyflow:
            inputArray = layer.datasources[0].request((slice(None),)).wait()
            expDlg = ExportDialog(parent = menu)
            g = Graph()
            piper = OpArrayPiper(g)
            piper.inputs["Input"].setValue(inputArray)
            expDlg.setInput(piper.outputs["Output"],g)
        expDlg.show()
        
    menu = QMenu("Menu", parent)
    title = QAction("%s" % layer.name, menu)
    title.setEnabled(False)
    
    export = QAction("Export...",menu)
    export.setStatusTip("Export Layer...")
    export.triggered.connect(onExport)
    
    menu.addAction(title)
    menu.addAction(export)
    menu.addSeparator()
    _add_actions( layer, menu )
    menu.exec_(pos)    
开发者ID:LimpingTwerp,项目名称:volumina,代码行数:33,代码来源:layercontextmenu.py

示例10: showMenu

# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addAction [as 别名]
 def showMenu( self ):
     """
     Creates a menu to display for the editing of template information.
     """
     item = self.uiMenuTREE.currentItem()
     
     menu = QMenu(self)
     act = menu.addAction('Add Menu...')
     act.setIcon(QIcon(projexui.resources.find('img/folder.png')))
     act.triggered.connect(self.createMenu)
     
     if ( item and item.data(0, Qt.UserRole) == 'menu' ):
         act = menu.addAction('Rename Menu...')
         ico = QIcon(projexui.resources.find('img/edit.png'))
         act.setIcon(ico)
         act.triggered.connect(self.renameMenu)
     
     act = menu.addAction('Add Separator')
     act.setIcon(QIcon(projexui.resources.find('img/ui/splitter.png')))
     act.triggered.connect(self.createSeparator)
     
     menu.addSeparator()
     
     act = menu.addAction('Remove Item')
     act.setIcon(QIcon(projexui.resources.find('img/remove.png')))
     act.triggered.connect(self.removeItem)
     act.setEnabled(item is not None)
     
     menu.exec_(QCursor.pos())
开发者ID:satishgoda,项目名称:DPS_PIPELINE,代码行数:31,代码来源:xmenutemplatewidget.py

示例11: MenuView

# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addAction [as 别名]
class MenuView(object):

    def __init__(self, menu, parent, main):
        self._main = main
        self._parent = parent

        self.hideConsoleAction = menu.addAction('Show/Hide &Console (F4)')
        self.hideConsoleAction.setCheckable(True)
        self.hideEditorAction = menu.addAction('Show/Hide &Editor (F3)')
        self.hideEditorAction.setCheckable(True)
        self.hideAllAction = menu.addAction('Show/Hide &All (F11)')
        self.hideAllAction.setCheckable(True)
        self.hideExplorerAction = menu.addAction('Show/Hide &Explorer (F2)')
        self.hideExplorerAction.setCheckable(True)
        menu.addSeparator()
        splitTabHAction = menu.addAction(QIcon(resources.images['splitH']), 'Split Tabs Horizontally (F10)')
        splitTabVAction = menu.addAction(QIcon(resources.images['splitV']), 'Split Tabs Vertically (F9)')
        menu.addSeparator()
        #Panels Properties
        self.menuProperties = QMenu('Panels Properties')
        self.splitCentralOrientation = self.menuProperties.addAction('Change Central Splitter Orientation')
        self.splitMainOrientation = self.menuProperties.addAction('Change Main Splitter Orientation')
        self.menuProperties.addSeparator()
        self.splitCentralRotate = self.menuProperties.addAction(QIcon(resources.images['splitCRotate']), 'Rotate Central Panels')
        self.splitMainRotate = self.menuProperties.addAction(QIcon(resources.images['splitMRotate']), 'Rotate GUI Panels')
        menu.addMenu(self.menuProperties)
        menu.addSeparator()
        #Zoom
        zoomInAction = menu.addAction('Zoom &In ('+OS_KEY+'+Wheel-Up)')
        zoomOutAction = menu.addAction('Zoom &Out ('+OS_KEY+'+Wheel-Down)')
        menu.addSeparator()
        fadeInAction = menu.addAction('Fade In (Alt+Wheel-Up)')
        fadeOutAction = menu.addAction('Fade Out (Alt+Wheel-Down)')

        self._parent._toolbar.addSeparator()
        self._parent._toolbar.addAction(splitTabHAction)
        self._parent._toolbar.addAction(splitTabVAction)

        QObject.connect(self.hideConsoleAction, SIGNAL("triggered()"), self._main._hide_container)
        QObject.connect(self.hideEditorAction, SIGNAL("triggered()"), self._main._hide_editor)
        QObject.connect(self.hideExplorerAction, SIGNAL("triggered()"), self._main._hide_explorer)
        QObject.connect(self.hideAllAction, SIGNAL("triggered()"), self._main._hide_all)
        QObject.connect(splitTabHAction, SIGNAL("triggered()"), lambda: self._main.split_tab(True))
        QObject.connect(splitTabVAction, SIGNAL("triggered()"), lambda: self._main.split_tab(False))
        QObject.connect(zoomInAction, SIGNAL("triggered()"), lambda: self._main._central.actual_tab().obtain_editor().zoom_in())
        QObject.connect(zoomOutAction, SIGNAL("triggered()"), lambda: self._main._central.actual_tab().obtain_editor().zoom_out())
        QObject.connect(self.splitCentralOrientation, SIGNAL("triggered()"), self._main._splitter_central_orientation)
        QObject.connect(self.splitMainOrientation, SIGNAL("triggered()"), self._main._splitter_main_orientation)
        QObject.connect(self.splitCentralRotate, SIGNAL("triggered()"), self._main._splitter_central_rotate)
        QObject.connect(self.splitMainRotate, SIGNAL("triggered()"), self._main._splitter_main_rotate)
        QObject.connect(fadeInAction, SIGNAL("triggered()"), self._fade_in)
        QObject.connect(fadeOutAction, SIGNAL("triggered()"), self._fade_out)

    def _fade_in(self):
        event = QWheelEvent(QPoint(), 120, Qt.NoButton, Qt.AltModifier)
        self._parent.wheelEvent(event)

    def _fade_out(self):
        event = QWheelEvent(QPoint(), -120, Qt.NoButton, Qt.AltModifier)
        self._parent.wheelEvent(event)
开发者ID:calpe20,项目名称:PYTHONIZANDO,代码行数:62,代码来源:menu_view.py

示例12: popup

# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addAction [as 别名]
    def popup(self, pos):

        from ui.ligne_edit import EditLigneViewWidget
        from ui.deleteview import DeleteViewWidget
        from data_helper import check_befor_update_data
        row = self.selectionModel().selection().indexes()[0].row()
        if (len(self.data) - 1) < row:
            return False
        menu = QMenu()
        editaction = menu.addAction("Modifier cette ligne")
        delaction = menu.addAction("Supprimer cette ligne")
        action = menu.exec_(self.mapToGlobal(pos))
        report = Report.get(id=self.data[row][-1])
        if action == editaction:
            try:
                self.parent.open_dialog(EditLigneViewWidget, modal=True,
                                        table_p=self, report=report)
            except IndexError:
                pass
        if action == delaction:
            list_error = check_befor_update_data(report)
            if list_error == []:
                if len(self.data) < 2:
                    self.parent.cancellation()
                else:
                    self.parent.open_dialog(
                        DeleteViewWidget, modal=True, obj=report, table_p=self,)
            else:
                from Common.ui.util import raise_error
                raise_error(u"Impossible de supprimer", """<h3>L'article {} :</h3>
                        Aura <b>{}</b> comme dernier restant.""".format(
                    report.product.name, list_error[-1]))
开发者ID:Ciwara,项目名称:GCiss,代码行数:34,代码来源:invoice_show.py

示例13: showCellContextMenu

# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addAction [as 别名]
    def showCellContextMenu(self, point):
        """Display the menu that occurs when right clicking on a table cell."""
        
        clickedCell = self.indexAt(point)

        if not clickedCell.isValid():
            # User clicked on a part of the table without a cell
            return False

        cellMenu = QMenu(self)
        insertCellAction = QAction("Insert Cells", cellMenu)
        deleteCellAction = QAction("Delete Cells", cellMenu)
        
        cellMenu.addAction(insertCellAction)
        cellMenu.addAction(deleteCellAction)

        # Connect signals
        insertCellAction.triggered.connect(self.insertCells)
        deleteCellAction.triggered.connect(self.deleteCells)

        # Display menu
        cellMenu.exec_(self.mapToGlobal(point))

        # Disconnect signals
        insertCellAction.triggered.disconnect(self.insertCells)
        deleteCellAction.triggered.disconnect(self.deleteCells)
开发者ID:bbreslauer,项目名称:PySciPlot,代码行数:28,代码来源:QDataTableView.py

示例14: displayHandMenu

# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addAction [as 别名]
 def displayHandMenu(self, pt):
     def flipCard():
         for index in self.lvHand.selectedIndexes():
             self.handModel.flipCardAtIndex(index)
     menu = QMenu(self)
     menu.addAction("Flip", flipCard)
     menu.exec_(self.lvHand.mapToGlobal(pt))
开发者ID:mplamann,项目名称:PTG,代码行数:9,代码来源:QPTG.py

示例15: customContext

# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import addAction [as 别名]
 def customContext(self, pos):
     index = self.listView.indexAt(pos)
     index = self.proxyModel.mapToSource(index)
     if not index.isValid():
         self.rmAction.setEnabled(False)
         self.openAction.setEnabled(False)
         self.loadAction.setEnabled(False)
     elif not self.model.isDir(index):
         info = self.model.fileInfo(index)
         suffix = info.suffix()
         if suffix in ("Rd","Rdata","RData"):
             self.loadAction.setEnabled(True)
             self.openAction.setEnabled(False)
             self.loadExternal.setEnabled(False)
         elif suffix in ("txt","csv","R","r"):
             self.openAction.setEnabled(True)
             self.loadAction.setEnabled(False)
             self.loadExternal.setEnabled(True)
         else:
             self.loadAction.setEnabled(False)
             self.openAction.setEnabled(False)
             self.loadExternal.setEnabled(True)
     menu = QMenu(self)
     for action in self.actions:
         menu.addAction(action)
     menu.exec_(self.listView.mapToGlobal(pos))
开发者ID:wioota,项目名称:ftools-qgis,代码行数:28,代码来源:widgets.py


注:本文中的PyQt4.QtGui.QMenu.addAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。