當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。