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


Python QtWidgets.QMenu方法代码示例

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


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

示例1: createMenu

# 需要导入模块: from qgis.PyQt import QtWidgets [as 别名]
# 或者: from qgis.PyQt.QtWidgets import QMenu [as 别名]
def createMenu(self, position):
        '''
        Creates the popup menu that allows extension insertion and removal
        position: mouse click position
        '''
        menu = QMenu()
        
        item = self.treeWidget.itemAt(position)

        if not item:
            menu.addAction(self.tr('Insert Extension'), self.insertExtension)
        else:        
            if self.depth(item) == 1:
                menu.addAction(self.tr('Remove Extension'), self.removeExtension)
            
        menu.exec_(self.treeWidget.viewport().mapToGlobal(position)) 
开发者ID:dsgoficial,项目名称:DsgTools,代码行数:18,代码来源:inventoryTools.py

示例2: initGui

# 需要导入模块: from qgis.PyQt import QtWidgets [as 别名]
# 或者: from qgis.PyQt.QtWidgets import QMenu [as 别名]
def initGui(self):
        #import pydevd
        #pydevd.settrace('localhost', port=9921, stdoutToServer=True, stderrToServer=True, suspend=False)

        # Register plugin layer type
        self.tileLayerType = TileLayerType(self)
        qgisRegistryInstance.addPluginLayerType(self.tileLayerType)

        # Create menu
        icon_path = self.plugin_dir + '/icons/mActionAddLayer.svg'
        self.menu = QMenu(self.tr(u'QuickMapServices'))
        self.menu.setIcon(QIcon(icon_path))
        self.init_server_panel()

        self.build_menu_tree()

        # add to QGIS menu/toolbars
        self.append_menu_buttons() 
开发者ID:nextgis,项目名称:quickmapservices,代码行数:20,代码来源:quick_map_services.py

示例3: __init__

# 需要导入模块: from qgis.PyQt import QtWidgets [as 别名]
# 或者: from qgis.PyQt.QtWidgets import QMenu [as 别名]
def __init__(self, iface, parent=None):
        """Constructor."""
        super(ProjectConfigurationDialog, self).__init__(parent=parent)
        self.iface = iface

        self.accepted.connect(self.onAccepted)
        self.project = QgsProject.instance()
        self.__project_configuration = ProjectConfiguration(self.project)

        self.setupUi(self)
        self.multipleToggleButton.setIcon(QIcon(os.path.join(os.path.dirname(__file__), '../resources/visibility.svg')))

        self.toggle_menu = QMenu(self)
        self.remove_all_action = QAction(self.tr("remove all layers"), self.toggle_menu)
        self.toggle_menu.addAction(self.remove_all_action)
        self.remove_hidden_action = QAction(self.tr("remove hidden layers"), self.toggle_menu)
        self.toggle_menu.addAction(self.remove_hidden_action)
        self.add_all_copy_action = QAction(self.tr("add all layers"), self.toggle_menu)
        self.toggle_menu.addAction(self.add_all_copy_action)
        self.add_visible_copy_action = QAction(self.tr("add visible layers"), self.toggle_menu)
        self.toggle_menu.addAction(self.add_visible_copy_action)
        self.add_all_offline_action = QAction(self.tr("add all vector layers as offline"), self.toggle_menu)
        self.toggle_menu.addAction(self.add_all_offline_action)
        self.add_visible_offline_action = QAction(self.tr("add visible vector layers as offline"), self.toggle_menu)
        self.toggle_menu.addAction(self.add_visible_offline_action)
        self.multipleToggleButton.setMenu(self.toggle_menu)
        self.multipleToggleButton.setAutoRaise(True)
        self.multipleToggleButton.setPopupMode(QToolButton.InstantPopup)
        self.toggle_menu.triggered.connect(self.toggle_menu_triggered)

        self.singleLayerRadioButton.toggled.connect(self.baseMapTypeChanged)
        self.unsupportedLayersList = list()

        self.reloadProject() 
开发者ID:opengisch,项目名称:qfieldsync,代码行数:36,代码来源:project_configuration_dialog.py

示例4: initGui

# 需要导入模块: from qgis.PyQt import QtWidgets [as 别名]
# 或者: from qgis.PyQt.QtWidgets import QMenu [as 别名]
def initGui(self):
        """Create the menu entries and toolbar icons inside the QGIS GUI."""

        self.menu = QMenu(self.tr('&DataPlotly'))
        self.iface.pluginMenu().addMenu(self.menu)

        # TODO: We are going to let the user set this up in a future iteration
        self.toolbar = self.iface.addToolBar('DataPlotly')
        self.toolbar.setObjectName('DataPlotly')

        self.dock_widget = DataPlotlyDock(message_bar=self.iface.messageBar())
        self.iface.addDockWidget(Qt.RightDockWidgetArea, self.dock_widget)
        self.dock_widget.hide()

        self.show_dock_action = QAction(
            GuiUtils.get_icon('dataplotly.svg'),
            self.tr('DataPlotly'))
        self.show_dock_action.setToolTip(self.tr('Shows the DataPlotly dock'))
        self.show_dock_action.setCheckable(True)

        self.dock_widget.setToggleVisibilityAction(self.show_dock_action)

        self.menu.addAction(self.show_dock_action)
        self.toolbar.addAction(self.show_dock_action)

        # Add processing provider
        self.initProcessing()

        # Add layout gui utils
        self.plot_item_gui_metadata = PlotLayoutItemGuiMetadata()
        QgsGui.layoutItemGuiRegistry().addLayoutItemGuiMetadata(self.plot_item_gui_metadata) 
开发者ID:ghtmtt,项目名称:DataPlotly,代码行数:33,代码来源:data_plotly.py

示例5: __init__

# 需要导入模块: from qgis.PyQt import QtWidgets [as 别名]
# 或者: from qgis.PyQt.QtWidgets import QMenu [as 别名]
def __init__(self, md, iface, parent):
        super(AddMeasurePointWidget, self).__init__(parent)
        self.setupUi(self)
        self.measureDialog = md
        self.iface = iface
        self.canvas = iface.mapCanvas()
        self.xymenu = QMenu()
        icon = QIcon(os.path.dirname(__file__) + '/images/yx.png')
        a = self.xymenu.addAction(icon, "Y, X (Lat, Lon) Order")
        a.setData(0)
        icon = QIcon(os.path.dirname(__file__) + '/images/xy.png')
        a = self.xymenu.addAction(icon, "X, Y (Lon, Lat) Order")
        a.setData(1)
        self.xyButton.setIconSize(QSize(24, 24))
        self.xyButton.setIcon(icon)
        self.xyButton.setMenu(self.xymenu)
        self.xyButton.triggered.connect(self.xyTriggered)

        self.crsmenu = QMenu()
        icon = QIcon(os.path.dirname(__file__) + '/images/wgs84Projection.png')
        a = self.crsmenu.addAction(icon, "WGS 84 (latitude & longitude)")
        a.setData(0)
        icon = QIcon(os.path.dirname(__file__) + '/images/projProjection.png')
        a = self.crsmenu.addAction(icon, "Project CRS")
        a.setData(1)
        icon = QIcon(os.path.dirname(__file__) + '/images/customProjection.png')
        a = self.crsmenu.addAction(icon, "Specify CRS")
        a.setData(2)
        self.crsButton.setIconSize(QSize(24, 24))
        self.crsButton.setIcon(icon)
        self.crsButton.setMenu(self.crsmenu)
        self.crsButton.triggered.connect(self.crsTriggered)

        self.addButton.clicked.connect(self.addPoint)
        self.exitButton.clicked.connect(self.closeDialog)

        self.readSettings()
        self.configButtons()
        
        self.restoreGeometry(QSettings().value("ShapeTools/AddMeasurePointGeometry", QByteArray(), type=QByteArray)) 
开发者ID:NationalSecurityAgency,项目名称:qgis-shapetools-plugin,代码行数:42,代码来源:geodesicMeasureTool.py

示例6: initGui

# 需要导入模块: from qgis.PyQt import QtWidgets [as 别名]
# 或者: from qgis.PyQt.QtWidgets import QMenu [as 别名]
def initGui(self):
        """
        Create the menu entries and toolbar icons inside the QGIS GUI
        """

        self.dsgTools = QMenu(self.iface.mainWindow())
        self.dsgTools.setObjectName(u'DsgTools')
        self.dsgTools.setTitle(u'DSGTools')
        self.menuBar.insertMenu(self.iface.firstRightStandardMenu().menuAction(), self.dsgTools)
        #GuiManager
        self.guiManager = GuiManager(self.iface, parentMenu = self.dsgTools, toolbar = self.toolbar)
        self.guiManager.initGui()
        #provider
        QgsApplication.processingRegistry().addProvider(self.provider) 
开发者ID:dsgoficial,项目名称:DsgTools,代码行数:16,代码来源:dsg_tools.py

示例7: createMenuAssigned

# 需要导入模块: from qgis.PyQt import QtWidgets [as 别名]
# 或者: from qgis.PyQt.QtWidgets import QMenu [as 别名]
def createMenuAssigned(self, position):
        '''
        Creates a pop up menu
        '''
        menu = QMenu()
        item = self.treeWidget.itemAt(position)
        if item:
            menu.addAction(self.tr('Show properties'), self.showAssignedProperties)
        menu.exec_(self.treeWidget.viewport().mapToGlobal(position)) 
开发者ID:dsgoficial,项目名称:DsgTools,代码行数:11,代码来源:exploreDb.py

示例8: createDbPerspectiveContextMenu

# 需要导入模块: from qgis.PyQt import QtWidgets [as 别名]
# 或者: from qgis.PyQt.QtWidgets import QMenu [as 别名]
def createDbPerspectiveContextMenu(self, position):
        menu = QMenu()
        item = self.permissionTreeWidget.itemAt(position)
        if item:
            if item.text(0) != '':
                menu.addAction(self.tr('Revoke all permissions'), self.revokeAll)
            elif item.text(1) != '':
                menu.addAction(self.tr('Manage User Permissions'), self.manageUserPermissions)
            elif item.text(2) != '':
                menu.addAction(self.tr('Revoke User'), self.revokeSelectedUser)
        menu.exec_(self.permissionTreeWidget.viewport().mapToGlobal(position)) 
开发者ID:dsgoficial,项目名称:DsgTools,代码行数:13,代码来源:permissionWidget.py

示例9: createUserPerspectiveContextMenu

# 需要导入模块: from qgis.PyQt import QtWidgets [as 别名]
# 或者: from qgis.PyQt.QtWidgets import QMenu [as 别名]
def createUserPerspectiveContextMenu(self, position):
        menu = QMenu()
        item = self.permissionTreeWidget.itemAt(position)
        if item:
            if item.text(0) != '':
                menu.addAction(self.tr('Revoke permissions on all granted databases'), self.revokeAllDbs)
            elif item.text(1) != '':
                menu.addAction(self.tr('Manage Permissions on database'), self.managePermissionsOnDb)
            elif item.text(2) != '':
                menu.addAction(self.tr('Revoke Permission'), self.revokeSelectedPermission)
        menu.exec_(self.permissionTreeWidget.viewport().mapToGlobal(position)) 
开发者ID:dsgoficial,项目名称:DsgTools,代码行数:13,代码来源:permissionWidget.py

示例10: createDbPerspectiveContextMenu

# 需要导入模块: from qgis.PyQt import QtWidgets [as 别名]
# 或者: from qgis.PyQt.QtWidgets import QMenu [as 别名]
def createDbPerspectiveContextMenu(self, position):
        menu = QMenu()
        item = self.treeWidget.itemAt(position)
        if item:
            if item.text(0) != '':
                menu.addAction(self.tr('Uninstall all settings from selected database'), self.uninstallSettings)
                menu.addAction(self.tr('Manage settings from selected database'), self.manageDbSettings)
            elif item.text(1) != '':
                menu.addAction(self.tr('Update selected setting'), self.updateSelectedSetting)
                menu.addAction(self.tr('Clone selected setting'), self.cloneSelectedSetting)
                menu.addAction(self.tr('Uninstall selected setting'), self.uninstallSettings)
                menu.addAction(self.tr('Delete selected setting'), self.deleteSelectedSetting)
        menu.exec_(self.treeWidget.viewport().mapToGlobal(position)) 
开发者ID:dsgoficial,项目名称:DsgTools,代码行数:15,代码来源:genericManagerWidget.py

示例11: createMenuInstalled

# 需要导入模块: from qgis.PyQt import QtWidgets [as 别名]
# 或者: from qgis.PyQt.QtWidgets import QMenu [as 别名]
def createMenuInstalled(self, position):
        """
        Creates a pop up menu to show permission properties
        """
        menu = QMenu()
        
        item = self.installedProfiles.itemAt(position)

        if item:        
            menu.addAction(self.tr('Show properties'), self.showInstalledProperties)
            
        menu.exec_(self.installedProfiles.viewport().mapToGlobal(position)) 
开发者ID:dsgoficial,项目名称:DsgTools,代码行数:14,代码来源:user_profiles.py

示例12: createMenuAssigned

# 需要导入模块: from qgis.PyQt import QtWidgets [as 别名]
# 或者: from qgis.PyQt.QtWidgets import QMenu [as 别名]
def createMenuAssigned(self, position):
        """
        Creates a pop up menu to show properties of a permission assigned to a user
        """
        menu = QMenu()

        item = self.assignedProfiles.itemAt(position)

        if item:
            menu.addAction(self.tr('Show properties'), self.showAssignedProperties)

        menu.exec_(self.assignedProfiles.viewport().mapToGlobal(position)) 
开发者ID:dsgoficial,项目名称:DsgTools,代码行数:14,代码来源:user_profiles.py

示例13: addMenu

# 需要导入模块: from qgis.PyQt import QtWidgets [as 别名]
# 或者: from qgis.PyQt.QtWidgets import QMenu [as 别名]
def addMenu(self, name, title, icon_file, parentMenu = None):
        """
        Adds a QMenu
        """
        child = QMenu(self.menu)
        child.setObjectName(name)
        child.setTitle(self.tr(title))
        child.setIcon(QIcon(self.iconBasePath+icon_file))
        if parentMenu:
            parentMenu.addMenu(child)
        else:
            self.menu.addMenu(child)
        self.menuList.append(child)
        return child 
开发者ID:dsgoficial,项目名称:DsgTools,代码行数:16,代码来源:guiManager.py

示例14: createContextMenuOnPosition

# 需要导入模块: from qgis.PyQt import QtWidgets [as 别名]
# 或者: from qgis.PyQt.QtWidgets import QMenu [as 别名]
def createContextMenuOnPosition(self, e, layer):
        menu = QMenu()
        callbackDict = dict()
        fieldList = [field.name() for field in layer.fields() if field.isNumeric()]
        for field in fieldList:
            action = menu.addAction(field)
            callback = partial(self.handleFeatures, field, layer)
            action.triggered.connect(callback)
        menu.exec_(self.canvas.viewport().mapToGlobal(e.pos())) 
开发者ID:dsgoficial,项目名称:DsgTools,代码行数:11,代码来源:assignBandValueTool.py

示例15: _read_ini_file

# 需要导入模块: from qgis.PyQt import QtWidgets [as 别名]
# 或者: from qgis.PyQt.QtWidgets import QMenu [as 别名]
def _read_ini_file(self, root, ini_file_path, category):
        try:
            ini_full_path = os.path.join(root, ini_file_path)
            parser = configparser.ConfigParser()
            with codecs.open(ini_full_path, 'r', 'utf-8') as ini_file:
                
                if hasattr(parser, "read_file"):
                    parser.read_file(ini_file)
                else:
                    parser.readfp(ini_file)
                #read config
                group_id = parser.get('general', 'id')
                group_alias = parser.get('ui', 'alias')
                icon_file = ConfigReaderHelper.try_read_config(parser, 'ui', 'icon')
                group_icon_path = os.path.join(root, icon_file) if icon_file else None
                #try read translations
                posible_trans = parser.items('ui')
            
            for key, val in posible_trans:
                if type(key) is unicode and key == 'alias[%s]' % self.locale:
                    self.translator.append(group_alias, val)
                    break
            #create menu
            group_menu = QMenu(self.tr(group_alias))
            group_menu.setIcon(QIcon(group_icon_path))
            #append to all groups
            # set contrib&user
            self.groups[group_id] = GroupInfo(group_id, group_alias, group_icon_path, ini_full_path, group_menu, category)
        except Exception as e:
            error_message = self.tr('Group INI file can\'t be parsed: ') + e.message
            QgsMessageLog.logMessage(error_message, level=QgsMessageLog.CRITICAL) 
开发者ID:nextgis,项目名称:quickmapservices,代码行数:33,代码来源:groups_list.py


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