Python qgis.PyQt.QtWidgets.QMenu() Examples
The following are 20
code examples of qgis.PyQt.QtWidgets.QMenu().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
qgis.PyQt.QtWidgets
, or try the search function
.
Example #1
Source File: quick_map_services.py From quickmapservices with GNU General Public License v2.0 | 6 votes |
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()
Example #2
Source File: inventoryTools.py From DsgTools with GNU General Public License v2.0 | 6 votes |
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))
Example #3
Source File: project_configuration_dialog.py From qfieldsync with GNU Lesser General Public License v3.0 | 5 votes |
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()
Example #4
Source File: groups_list.py From quickmapservices with GNU General Public License v2.0 | 5 votes |
def get_group_menu(self, group_id): if group_id in self.groups: return self.groups[group_id].menu else: info = GroupInfo(group_id=group_id, menu=QMenu(group_id)) self.groups[group_id] = info return info.menu # noinspection PyMethodMayBeStatic
Example #5
Source File: groups_list.py From quickmapservices with GNU General Public License v2.0 | 5 votes |
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)
Example #6
Source File: assignBandValueTool.py From DsgTools with GNU General Public License v2.0 | 5 votes |
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()))
Example #7
Source File: guiManager.py From DsgTools with GNU General Public License v2.0 | 5 votes |
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
Example #8
Source File: user_profiles.py From DsgTools with GNU General Public License v2.0 | 5 votes |
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))
Example #9
Source File: user_profiles.py From DsgTools with GNU General Public License v2.0 | 5 votes |
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))
Example #10
Source File: genericManagerWidget.py From DsgTools with GNU General Public License v2.0 | 5 votes |
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))
Example #11
Source File: permissionWidget.py From DsgTools with GNU General Public License v2.0 | 5 votes |
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))
Example #12
Source File: permissionWidget.py From DsgTools with GNU General Public License v2.0 | 5 votes |
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))
Example #13
Source File: exploreDb.py From DsgTools with GNU General Public License v2.0 | 5 votes |
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))
Example #14
Source File: dsg_tools.py From DsgTools with GNU General Public License v2.0 | 5 votes |
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)
Example #15
Source File: geodesicMeasureTool.py From qgis-shapetools-plugin with GNU General Public License v2.0 | 5 votes |
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))
Example #16
Source File: data_plotly.py From DataPlotly with GNU General Public License v2.0 | 5 votes |
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)
Example #17
Source File: genericSelectionTool.py From DsgTools with GNU General Public License v2.0 | 4 votes |
def setContextMenuStyle(self, e, dictMenuSelected, dictMenuNotSelected): """ Defines how many "submenus" the context menu should have. There are 3 context menu scenarios to be handled: :param e: (QMouseEvent) mouse event on canvas. :param dictMenuSelected: (dict) dictionary of classes and its selected features being treatead. :param dictMenuNotSelected: (dict) dictionary of classes and its non selected features being treatead. """ # finding out filling conditions selectedDict = bool(dictMenuSelected) notSelectedDict = bool(dictMenuNotSelected) # finding out if one of either dictionaty are filled ("Exclusive or") selectedXORnotSelected = (selectedDict != notSelectedDict) # setting "All"-command name if e.button() == Qt.RightButton: genericAction = self.tr('Open All Feature Forms') else: genericAction = self.tr('Select All Features') # in case one of given dict is empty if selectedXORnotSelected: if selectedDict: menuDict, menu = dictMenuSelected, QMenu(title=self.tr('Selected Features')) genericAction = self.tr('Deselect All Features') # if the dictionary is from selected features, we want commands to be able to deselect them selectAll = False else: menuDict, menu = dictMenuNotSelected, QMenu(title=self.tr('Not Selected Features')) genericAction = self.tr('Select All Features') # if the dictionary is from non-selected features, we want commands to be able to select them selectAll = True if e.button() == Qt.RightButton: genericAction = self.tr('Open All Feature Forms') self.createSubmenu(e=e, parentMenu=menu, menuDict=menuDict, genericAction=genericAction, selectAll=selectAll) if len(menuDict) != 1 and len(list(menuDict.values())) > 1: # if there's only one class, "All"-command is given by createSubmenu method action = menu.addAction(genericAction) triggeredAction, hoveredAction = self.getCallbackMultipleFeatures(e=e, dictLayerFeature=menuDict, selectAll=selectAll) self.addCallBackToAction(action=action, onTriggeredAction=triggeredAction, onHoveredAction=hoveredAction) elif selectedDict: # if both of them is empty one more QMenu level is added menu = QMenu() selectedMenu = QMenu(title=self.tr('Selected Features')) notSelectedMenu = QMenu(title=self.tr('Not Selected Features')) menu.addMenu(selectedMenu) menu.addMenu(notSelectedMenu) selectedGenericAction = self.tr('Deselect All Features') notSelectedGenericAction = self.tr('Select All Features') # selectAll is set to True as now we want command to Deselect Features in case they are selected self.createSubmenu(e=e, parentMenu=selectedMenu, menuDict=dictMenuSelected, genericAction=selectedGenericAction, selectAll=False) if len(dictMenuSelected) != 1 and len(list(dictMenuSelected.values())) > 1: # if there's only one class, "All"-command is given by createSubmenu method action = selectedMenu.addAction(selectedGenericAction) triggeredAction, hoveredAction = self.getCallbackMultipleFeatures(e=e, dictLayerFeature=dictMenuSelected, selectAll=False) self.addCallBackToAction(action=action, onTriggeredAction=triggeredAction, onHoveredAction=hoveredAction) self.createSubmenu(e=e, parentMenu=notSelectedMenu, menuDict=dictMenuNotSelected, genericAction=notSelectedGenericAction, selectAll=True) if len(dictMenuNotSelected) != 1 and len(list(dictMenuNotSelected.values())) > 1: # if there's only one class, "All"-command is given by createSubmenu method action = notSelectedMenu.addAction(notSelectedGenericAction) triggeredAction, hoveredAction = self.getCallbackMultipleFeatures(e=e, dictLayerFeature=dictMenuNotSelected, selectAll=True) self.addCallBackToAction(action=action, onTriggeredAction=triggeredAction, onHoveredAction=hoveredAction) menu.exec_(self.canvas.viewport().mapToGlobal(e.pos()))
Example #18
Source File: viewer_controls.py From albion with GNU General Public License v3.0 | 4 votes |
def __init__(self, viewer, iface=None, parent=None): super(ViewerControls, self).__init__(parent) uic.loadUi(os.path.join(os.path.dirname(__file__), 'viewer_3d_controls.ui'), self) self.__viewer = viewer self.__viewer.setZscale(self.zScaleSlider.value()) self.__viewer.setTransparencyPercent(self.transparencySlider.value()) menu = QMenu() for l, c, t in [ ('labels', self.__viewer.toggle_labels, False), ('nodes', self.__viewer.toggle_nodes, True), ('edges', self.__viewer.toggle_edges, True), ('ends', self.__viewer.toggle_ends, True), ('volumes', self.__viewer.toggle_volumes, False), ('volumes sections', self.__viewer.toggle_volumes_section, True), ('errors', self.__viewer.toggle_errors, False), ]: a = menu.addAction(l) a.setCheckable(True) a.triggered.connect(c) a.setChecked(t) c(t) self.layerButton.setMenu(menu) self.zScaleSlider.valueChanged.connect(self.__viewer.setZscale) self.transparencySlider.valueChanged.connect(self.__viewer.setTransparencyPercent) self.refreshButton.clicked.connect(self.__viewer.refresh_data) self.xyButton.clicked.connect(self.__viewer.set_xy_pov) self.deleteButton.setCheckable(True) self.addButton.setCheckable(True) self.deleteButton.clicked.connect(partial(self.addButton.setChecked, False)) self.addButton.clicked.connect(partial(self.deleteButton.setChecked, False)) self.deleteButton.clicked.connect(self.__viewer.set_delete_tool) self.addButton.clicked.connect(self.__viewer.set_add_tool) self.__iface = iface
Example #19
Source File: digitizer.py From qgis-latlontools-plugin with GNU General Public License v2.0 | 4 votes |
def __init__(self, lltools, iface, parent): super(DigitizerWidget, self).__init__(parent) self.setupUi(self) self.lltools = lltools 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/mgrsProjection.png') a = self.crsmenu.addAction(icon, "MGRS") a.setData(1) icon = QIcon(os.path.dirname(__file__) + '/images/projProjection.png') a = self.crsmenu.addAction(icon, "Project CRS") a.setData(2) icon = QIcon(os.path.dirname(__file__) + '/images/customProjection.png') a = self.crsmenu.addAction(icon, "Specify CRS") a.setData(3) icon = QIcon(os.path.dirname(__file__) + '/images/pluscodes.png') a = self.crsmenu.addAction(icon, "Plus Codes") a.setData(4) icon = QIcon(os.path.dirname(__file__) + '/images/utm.png') a = self.crsmenu.addAction(icon, "UTM") a.setData(5) self.crsButton.setIconSize(QSize(24, 24)) self.crsButton.setIcon(icon) self.crsButton.setMenu(self.crsmenu) self.crsButton.triggered.connect(self.crsTriggered) self.iface.currentLayerChanged.connect(self.currentLayerChanged) self.addButton.clicked.connect(self.addFeature) self.exitButton.clicked.connect(self.exit) self.readSettings() self.configButtons()
Example #20
Source File: opeNoise.py From openoise-map with GNU General Public License v3.0 | 4 votes |
def initGui(self): # opeNoise self.opeNoise_menu = QMenu(QCoreApplication.translate("opeNoise", "&opeNoise")) self.opeNoise_menu.setIcon(QIcon(":/plugins/opeNoise/icons/icon_opeNoise.png")) # CreateReceiverPoints # self.CreateReceiverPoints_item = QAction(QIcon(":/plugins/opeNoise/icons/icon_CreateReceiverPoints.png"), # QCoreApplication.translate("opeNoise", self.tr("Create Receiver Points")), self.iface.mainWindow()) self.CreateReceiverPoints_item = QAction(QIcon(":/plugins/opeNoise/icons/icon_CreateReceiverPoints.png"), self.tr("Create Receiver Points"), self.iface.mainWindow()) self.CreateReceiverPoints_item.triggered.connect(self.CreateReceiverPoints_show) # CalculateNoiseLevels self.CalculateNoiseLevels_item = QAction(QIcon(":/plugins/opeNoise/icons/icon_CalculateNoiseLevels.png"), self.tr("Calculate Noise Levels"), self.iface.mainWindow()) self.CalculateNoiseLevels_item.triggered.connect(self.CalculateNoiseLevels_show) # AssignLevelsToBuildings self.AssignLevelsToBuildings_item = QAction(QIcon(":/plugins/opeNoise/icons/icon_AssignLevelsToBuildings.png"), self.tr("Assign Levels To Buildings"), self.iface.mainWindow()) self.AssignLevelsToBuildings_item.triggered.connect(self.AssignLevelsToBuildings_show) # AssignLevelsToBuildings self.ApplyNoiseSymbology_item = QAction(QIcon(":/plugins/opeNoise/icons/icon_ApplyNoiseSymbology.png"), QCoreApplication.translate("opeNoise", "Apply Noise Symbology"), self.iface.mainWindow()) self.ApplyNoiseSymbology_item.triggered.connect(self.ApplyNoiseSymbology_show) # Information self.Informations_item = QAction(QIcon(":/plugins/opeNoise/icons/icon_Informations.png"), QCoreApplication.translate("opeNoise", "Information"), self.iface.mainWindow()) self.Informations_item.triggered.connect(self.Informations_show) # Credits self.Credits_item = QAction(QIcon(":/plugins/opeNoise/icons/icon_Credits.png"), QCoreApplication.translate("opeNoise", "Credits"), self.iface.mainWindow()) self.Credits_item.triggered.connect(self.Credits_show) # add items self.opeNoise_menu.addActions([self.CreateReceiverPoints_item, self.CalculateNoiseLevels_item, self.AssignLevelsToBuildings_item, self.ApplyNoiseSymbology_item, self.Informations_item, self.Credits_item]) self.menu = self.iface.pluginMenu() self.menu.addMenu( self.opeNoise_menu )