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


Python QMenu.isEmpty方法代码示例

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


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

示例1: process_custom_menu

# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import isEmpty [as 别名]
    def process_custom_menu(self, point):
        ''' See XmlController for documentation '''
        item = self.select_item_at(point)
        if not item:
            return
        menu = QMenu()
        node = item.node

        if node.get('executable') == 'True':
            menu.addAction(self.actRunScenario)
        elif node.get('type') in ['selectable', 'model_choice']:
            menu.addAction(self.actMoveNodeUp)
            menu.addAction(self.actMoveNodeDown)
        elif node.tag == 'models_to_run': # special case of a selectable list
            models_menu = QMenu(menu)
            models_menu.setTitle('Add model to run')
            models_menu.setIcon(IconLibrary.icon('add'))
            available_model_names = get_model_names(self.project)
            for model_name in available_model_names:
                cb = lambda x = model_name, y = self.selected_index(): self.addModel(y, x)
                action = self.create_action('model', model_name, cb)
                models_menu.addAction(action)
            menu.addMenu(models_menu)

        self.add_default_menu_items_for_node(node, menu)

        if not menu.isEmpty():
            menu.exec_(QCursor.pos())
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:30,代码来源:xml_controller_scenarios.py

示例2: contextMenuEvent

# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import isEmpty [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: process_custom_menu

# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import isEmpty [as 别名]
    def process_custom_menu(self, point):
        item = self.select_item_at(point)
        if not item:
            return

        node = item.node
        menu = QMenu(self.view)

        # Populate menu
        if node.tag == 'run':
            menu.addAction(self.actGetInfoSimulationRuns)
            menu.addAction(self.actDeleteRun)
        elif node.tag == 'indicator_batches':
            menu.addAction(self.actAddNewIndicatorBatch)
        elif node.tag == 'simulation_runs':
            menu.addAction(self.actImportRun)
        elif node.tag == 'indicator_batch':
            menu.addAction(self.actAddVisualizationToBatch)
            run_batch_on_menu = QMenu('Run indicator batch on...')
            self._createBatchRunMenu(run_batch_on_menu)
            menu.addMenu(run_batch_on_menu)

        elif node.tag == 'batch_visualization': # get('type') == 'batch_visualization':
            menu.addAction(self.actConfigureExistingBatchIndicatorVis)

        self.add_default_menu_items_for_node(node, menu)

        if not menu.isEmpty():
            menu.exec_(QCursor.pos())
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:31,代码来源:xml_controller_results.py

示例4: process_custom_menu

# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import isEmpty [as 别名]
    def process_custom_menu(self, position):
        '''
        Abstract method for creating a context sensitive popup menu.
        @param position (QPoint) point of request for the popupmenu.
        '''
        item = self.select_item_at(position)
        if not item:
            return
        node = item.node

        menu = QMenu(self.view)
        self.add_default_menu_items_for_node(node, menu)
        if not menu.isEmpty():
            menu.exec_(QCursor.pos())
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:16,代码来源:xml_controller.py

示例5: process_custom_menu

# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import isEmpty [as 别名]
    def process_custom_menu(self, point):
        ''' See XmlConfig.processCustomMenu for documentation '''
        index = self.select_item_at(point)
        if not index:
            return

        node = self.selected_item().node
        menu = QMenu(self.view)

        if node.tag == 'models':
            submenu = QMenu(menu) # to populate with templates
            submenu.setTitle('Create model from template')
            for action in self.create_from_template_actions:
                submenu.addAction(action)
            menu.addMenu(submenu)

        if node.tag == 'model':
            # If the users right clicks a model, give them the option to
            # estimate it only if the model has a (non empty) specification
            # subnode. If the model holds subgroups -- inform the user how to
            # estimate them.
            spec_node = node.find('specification')

            submodels = None
            if spec_node is not None:
                submodels = spec_node.getchildren()
            if spec_node is not None and submodels:
                # check if its groups by type checking the first node
                # note: this is not a reliable method if models can have mixed
                # submodels and submodel groups.
                if submodels[0].tag == 'submodel':
                    menu.addAction(self.action_run_estimation)
                else:
                    menu.addAction(self.action_show_how_to_estimate_groups)

        if node.tag == 'submodel' and not node.get('inherited'):
            menu.addAction(self.action_edit_submodel)

        if node.tag == 'submodel_group':
            menu.addAction(self.action_run_estimation_group)

        self.add_default_menu_items_for_node(node, menu)

        if not menu.isEmpty():
            menu.exec_(QCursor.pos())
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:47,代码来源:xml_controller_models.py

示例6: ProfileTableViewer

# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import isEmpty [as 别名]

#.........这里部分代码省略.........

    def __showContextMenu( self, point ):
        " Context menu "
        self.__callersMenu.clear()
        self.__outsideCallersMenu.clear()
        self.__calleesMenu.clear()
        self.__outsideCalleesMenu.clear()

        # Detect what the item was clicked
        item = self.__table.itemAt( point )

        funcName = item.getFunctionName()
        self.__disasmAct.setEnabled( item.getFileName() != "" and \
                                     not funcName.startswith( "<" ) )

        # Build the context menu
        if item.callersCount() == 0:
            self.__callersMenu.setEnabled( False )
            self.__outsideCallersMenu.setEnabled( False )
        else:
            callers = self.__stats.stats[ item.getFuncIDs() ][ 4 ]
            callersList = callers.keys()
            callersList.sort()
            for callerFunc in callersList:
                menuText = self.__getCallLine( callerFunc, callers[ callerFunc ] )
                if self.__isOutsideItem( callerFunc[ 0 ] ):
                    act = self.__outsideCallersMenu.addAction( menuText )
                else:
                    act = self.__callersMenu.addAction( menuText )
                funcFileName, funcLine, funcName = self.__getLocationAndName( callerFunc )
                act.setData( QVariant( funcFileName + ":" + \
                                       str( funcLine ) + ":" + \
                                       funcName ) )
            self.__callersMenu.setEnabled( not self.__callersMenu.isEmpty() )
            self.__outsideCallersMenu.setEnabled( not self.__outsideCallersMenu.isEmpty() )

        if item.calleesCount() == 0:
            self.__calleesMenu.setEnabled( False )
            self.__outsideCalleesMenu.setEnabled( False )
        else:
            callees = self.__stats.all_callees[ item.getFuncIDs() ]
            calleesList = callees.keys()
            calleesList.sort()
            for calleeFunc in calleesList:
                menuText = self.__getCallLine( calleeFunc, callees[ calleeFunc ] )
                if self.__isOutsideItem( calleeFunc[ 0 ] ):
                    act = self.__outsideCalleesMenu.addAction( menuText )
                else:
                    act = self.__calleesMenu.addAction( menuText )
                funcFileName, funcLine, funcName = self.__getLocationAndName( calleeFunc )
                act.setData( QVariant( funcFileName + ":" + \
                                       str( funcLine ) + ":" + \
                                       funcName ) )
            self.__calleesMenu.setEnabled( not self.__calleesMenu.isEmpty() )
            self.__outsideCalleesMenu.setEnabled( not self.__outsideCalleesMenu.isEmpty() )

        self.__contextMenu.popup( QCursor.pos() )
        return

    def __onDisassemble( self ):
        " On disassemble something "
        item = self.__table.selectedItems()[ 0 ]
        GlobalData().mainWindow.showDisassembler( item.getFileName(),
                                                  item.getFunctionName() )
        return
开发者ID:eaglexmw,项目名称:codimension,代码行数:69,代码来源:proftable.py

示例7: __init__

# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import isEmpty [as 别名]

#.........这里部分代码省略.........
        if self.GdalVersionNum >= 1600:
            self.buildVRT = QAction(QIcon(":/icons/vrt.png"), QCoreApplication.translate("GdalTools", "Build Virtual Raster (Catalog)..."), self.iface.mainWindow())
            self.buildVRT.setObjectName("buildVRT")
            self.buildVRT.setStatusTip(QCoreApplication.translate("GdalTools", "Builds a VRT from a list of datasets"))
            QObject.connect(self.buildVRT, SIGNAL("triggered()"), self.doBuildVRT)
            self.miscellaneousMenu.addAction(self.buildVRT)

        self.merge = QAction(QIcon(":/icons/merge.png"), QCoreApplication.translate("GdalTools", "Merge..."), self.iface.mainWindow())
        self.merge.setObjectName("merge")
        self.merge.setStatusTip(QCoreApplication.translate("GdalTools", "Build a quick mosaic from a set of images"))
        QObject.connect(self.merge, SIGNAL("triggered()"), self.doMerge)

        self.info = QAction(QIcon(":/icons/raster-info.png"), QCoreApplication.translate("GdalTools", "Information..."), self.iface.mainWindow())
        self.info.setObjectName("info")
        self.info.setStatusTip(QCoreApplication.translate("GdalTools", "Lists information about raster dataset"))
        QObject.connect(self.info, SIGNAL("triggered()"), self.doInfo)

        self.overview = QAction(QIcon(":icons/raster-overview.png"), QCoreApplication.translate("GdalTools", "Build Overviews (Pyramids)..."), self.iface.mainWindow())
        self.overview.setObjectName("overview")
        self.overview.setStatusTip(QCoreApplication.translate("GdalTools", "Builds or rebuilds overview images"))
        QObject.connect(self.overview, SIGNAL("triggered()"), self.doOverview)

        self.tileindex = QAction(QIcon(":icons/tiles.png"), QCoreApplication.translate("GdalTools", "Tile Index..."), self.iface.mainWindow())
        self.tileindex.setObjectName("tileindex")
        self.tileindex.setStatusTip(QCoreApplication.translate("GdalTools", "Build a shapefile as a raster tileindex"))
        QObject.connect(self.tileindex, SIGNAL("triggered()"), self.doTileIndex)

        self.miscellaneousMenu.addActions([self.merge, self.info, self.overview, self.tileindex])

        self._menuActions.append(self.menu.addMenu(self.projectionsMenu))
        self._menuActions.append(self.menu.addMenu(self.conversionMenu))
        self._menuActions.append(self.menu.addMenu(self.extractionMenu))

        if not self.analysisMenu.isEmpty():
            self._menuActions.append(self.menu.addMenu(self.analysisMenu))

        self._menuActions.append(self.menu.addMenu(self.miscellaneousMenu))

        self.settings = QAction(QCoreApplication.translate("GdalTools", "GdalTools Settings..."), self.iface.mainWindow())
        self.settings.setObjectName("settings")
        self.settings.setStatusTip(QCoreApplication.translate("GdalTools", "Various settings for Gdal Tools"))
        QObject.connect(self.settings, SIGNAL("triggered()"), self.doSettings)
        self.menu.addAction(self.settings)
        self._menuActions.append(self.settings)

    def unload(self):
        if not valid:
            return
        for a in self._menuActions:
            self.menu.removeAction(a)

    def doBuildVRT(self):
        from tools.doBuildVRT import GdalToolsDialog as BuildVRT
        d = BuildVRT(self.iface)
        self.runToolDialog(d)

    def doContour(self):
        from tools.doContour import GdalToolsDialog as Contour
        d = Contour(self.iface)
        self.runToolDialog(d)

    def doRasterize(self):
        from tools.doRasterize import GdalToolsDialog as Rasterize
        d = Rasterize(self.iface)
        self.runToolDialog(d)
开发者ID:boggins,项目名称:QGIS,代码行数:69,代码来源:GdalTools.py

示例8: _show_right_click_menu

# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import isEmpty [as 别名]
    def _show_right_click_menu(self, point):
        ''' handler for the when users right click on table variables_table '''
        index = self.variables_table.indexAt(point)
        if not index.isValid:
            return
        self.variables_table.setCurrentIndex(index)
        var = self.model.variables[index.row()]
        menu = QMenu(self.variables_table)

        # Edit variable action
        p = ('edit', 'Edit %s' % var['name'], lambda x=var: self._edit_variable(x), self)
        edit_action = create_qt_action(*p)
        font = QFont()
        font.setBold(True)
        edit_action.setFont(font)
        # Clone variable action
        p = ('clone', 'Create new variable based on this', lambda x=var: self._add_variable(x), self)
        clone_action = create_qt_action(*p)
        def make_local(var = var):
            if var['inherited']:
                var['dirty'] = True
                var['inherited'] = None
                self.model.dirty = True
            self._update_apply_button()
        def delete_var(var = var):
            self.model.delete_variable(var)
            self._update_apply_button()
        p = ('make_local', 'Make local', make_local, self)
        make_local_action = create_qt_action(*p)
        p = ('delete', 'Delete %s' % var['name'], delete_var, self)
        delete_action = create_qt_action(*p)
        p = ('revert', 'Revert %s to inherited' % var['name'], delete_var, self)
        revert_action = create_qt_action(*p)

        # check to see if we have graphviz installed
        p = ('zoom', 'View dependencies', lambda x=var: self._view_dependencies(x), self)
        view_dependencies_action = create_qt_action(*p)

        if var['inherited']:
#            menu.addAction(edit_action)
            menu.addAction(make_local_action)
            menu.addAction(clone_action)
            menu.addSeparator()
            menu.addAction(view_dependencies_action)
        else:
            menu.addAction(edit_action)
            menu.addAction(clone_action)
            menu.addSeparator()
            # if the node in the table is local, but the original is inherited OR
            # if the original node is shadowing an inherited node, allow user to 'revert'
            # instead of 'delete'. Read more about prototype nodes in opus_project.py.
            if var['originalnode'] is None:
                menu.addAction(delete_action)
            else:
                prototype_node = self.project.get_prototype_node(var['originalnode'])
                if var['originalnode'].get('inherited') or \
                    (prototype_node is not None and prototype_node.get('inherited')):
                    # This action will revert the node to the parent state. Show the values
                    # that it will revert to
                    tt = ('Revert %s to Name: %s, Definition: %s' % (var['name'],
                                                                     prototype_node.get('name'),
                                                                     prototype_node.text))
                    revert_action.setToolTip(tt)
                    menu.addAction(revert_action)
                else:
                    menu.addAction(delete_action)
            menu.addAction(view_dependencies_action)

        # Menu constructed, present to user
        if not menu.isEmpty():
            menu.exec_(QCursor.pos())
开发者ID:,项目名称:,代码行数:73,代码来源:

示例9: process_custom_menu

# 需要导入模块: from PyQt4.QtGui import QMenu [as 别名]
# 或者: from PyQt4.QtGui.QMenu import isEmpty [as 别名]
    def process_custom_menu(self, position):
        """ See XmlConfig.processCustomMenu for documentation """
        item = self.select_item_at(position)

        index = self.view.indexAt(position)
        cnt = self.model.rowCount(index.parent())

        istop = index.row() == 0
        isbottom = index.row() == cnt - 1
        isonly = cnt == 1

        if not item:
            return

        node = item.node
        menu = QMenu(self.view)

        # Tool files are the "actual" tools
        if node.tag == "tool":
            menu.addAction(self.actExecToolFile)
            if not isonly:
                menu.addSeparator()
            if not istop:
                menu.addAction(self.actMoveNodeUp)
            if not isbottom:
                menu.addAction(self.actMoveNodeDown)

        elif node.tag == "class_module":
            menu.addAction(self.actChangeClassModule)

        elif node.tag == "path_to_tool_modules":
            menu.addAction(self.actChangePathToTools)

        # "Tool library is a collection of tool groups
        elif node.tag == "tool_library":
            menu.addAction(self.actAddToolGroup)

        # Tool groups are groups of "tool files"
        elif node.tag == "tool_group":
            menu.addAction(self.actAddToolFile)
            if not isonly:
                menu.addSeparator()
            if not istop:
                menu.addAction(self.actMoveNodeUp)
            if not isbottom:
                menu.addAction(self.actMoveNodeDown)

        # Param Template is the parameter node for the tools -- where
        # users can build up a list of parameters that gets passed to the
        # tool function
        elif node.tag == "params":
            menu.addAction(self.actAddParam)

        elif node.tag == "param":
            menu.addAction(self.actEditParam)

        # A "tool config" is an alternative configuration for a tool that can be
        # put in a Tool Set
        elif node.tag == "tool_config":
            menu.addAction(self.actExecToolConfig)
            if not isonly:
                menu.addSeparator()
            if not istop:
                menu.addAction(self.actMoveNodeUp)
            if not isbottom:
                menu.addAction(self.actMoveNodeDown)

        # "Tool sets" is a collection of multiple tool sets
        elif node.tag == "tool_sets":
            menu.addAction(self.actAddNewToolSet)

        # A Tool set is a collection of (alternative) configurations for
        # existing tools.
        elif node.tag == "tool_set":
            menu.addAction(self.actExecBatch)
            menu.addSeparator()
            menu.addAction(self.actNewConfig)
            if not isonly:
                menu.addSeparator()
            if not istop:
                menu.addAction(self.actMoveNodeUp)
            if not isbottom:
                menu.addAction(self.actMoveNodeDown)

        elif node.tag == "documentation_path":
            menu.addAction(self.actOpenDocumentation)
            menu.addSeparator()
            menu.addAction(self.actCloneNode)

        # Default menu items
        self.add_default_menu_items_for_node(node, menu)

        # Now add the export and import methods
        menu.addSeparator()
        menu.addAction(self.actExportXMLToFile)
        menu.addAction(self.actImportXMLFromFile)

        # Check if the menu has any elements before exec is called
        if not menu.isEmpty():
            menu.exec_(QCursor.pos())
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:102,代码来源:xml_controller_data_tools.py


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