本文整理汇总了Python中qgis.PyQt.QtWidgets.QAction类的典型用法代码示例。如果您正苦于以下问题:Python QAction类的具体用法?Python QAction怎么用?Python QAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QAction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: initGui
def initGui(self):
self.action = QAction(
QIcon(":/db_manager/icon"), QApplication.translate("DBManagerPlugin", "DB Manager"), self.iface.mainWindow()
)
self.action.setObjectName("dbManager")
self.action.triggered.connect(self.run)
# Add toolbar button and menu item
if hasattr(self.iface, "addDatabaseToolBarIcon"):
self.iface.addDatabaseToolBarIcon(self.action)
else:
self.iface.addToolBarIcon(self.action)
if hasattr(self.iface, "addPluginToDatabaseMenu"):
self.iface.addPluginToDatabaseMenu(QApplication.translate("DBManagerPlugin", "DB Manager"), self.action)
else:
self.iface.addPluginToMenu(QApplication.translate("DBManagerPlugin", "DB Manager"), self.action)
self.layerAction = QAction(
QIcon(":/db_manager/icon"),
QApplication.translate("DBManagerPlugin", "Update Sql Layer"),
self.iface.mainWindow(),
)
self.layerAction.setObjectName("dbManagerUpdateSqlLayer")
self.layerAction.triggered.connect(self.onUpdateSqlLayer)
self.iface.legendInterface().addLegendLayerAction(
self.layerAction, "", "dbManagerUpdateSqlLayer", QgsMapLayer.VectorLayer, False
)
for l in QgsMapLayerRegistry.instance().mapLayers().values():
self.onLayerWasAdded(l)
QgsMapLayerRegistry.instance().layerWasAdded.connect(self.onLayerWasAdded)
开发者ID:CS-SI,项目名称:QGIS,代码行数:29,代码来源:db_manager_plugin.py
示例2: addAlgorithmEntry
def addAlgorithmEntry(alg, menuName, submenuName, actionText=None, icon=None, addButton=False):
if actionText is None:
if (QgsGui.higFlags() & QgsGui.HigMenuTextIsTitleCase) and not (alg.flags() & QgsProcessingAlgorithm.FlagDisplayNameIsLiteral):
alg_title = QgsStringUtils.capitalize(alg.displayName(), QgsStringUtils.TitleCase)
else:
alg_title = alg.displayName()
actionText = alg_title + QCoreApplication.translate('Processing', '…')
action = QAction(icon or alg.icon(), actionText, iface.mainWindow())
alg_id = alg.id()
action.setData(alg_id)
action.triggered.connect(lambda: _executeAlgorithm(alg_id))
action.setObjectName("mProcessingUserMenu_%s" % alg_id)
if menuName:
menu = getMenu(menuName, iface.mainWindow().menuBar())
submenu = getMenu(submenuName, menu)
submenu.addAction(action)
if addButton:
global algorithmsToolbar
if algorithmsToolbar is None:
algorithmsToolbar = iface.addToolBar(QCoreApplication.translate('MainWindow', 'Processing Algorithms'))
algorithmsToolbar.setObjectName("ProcessingAlgorithms")
algorithmsToolbar.setToolTip(QCoreApplication.translate('MainWindow', 'Processing Algorithms Toolbar'))
algorithmsToolbar.addAction(action)
开发者ID:dmarteau,项目名称:QGIS,代码行数:25,代码来源:menus.py
示例3: initGui
def initGui(self):
"""startup"""
# run
run_icon = QIcon('%s/%s' % (self.context.ppath,
'images/MetaSearch.png'))
self.action_run = QAction(run_icon, 'MetaSearch',
self.iface.mainWindow())
self.action_run.setWhatsThis(QCoreApplication.translate('MetaSearch',
'MetaSearch plugin'))
self.action_run.setStatusTip(QCoreApplication.translate('MetaSearch',
'Search Metadata Catalogs'))
self.action_run.triggered.connect(self.run)
self.iface.addWebToolBarIcon(self.action_run)
self.iface.addPluginToWebMenu(self.web_menu, self.action_run)
# help
help_icon = QgsApplication.getThemeIcon('/mActionHelpContents.svg')
self.action_help = QAction(help_icon, 'Help', self.iface.mainWindow())
self.action_help.setWhatsThis(QCoreApplication.translate('MetaSearch',
'MetaSearch plugin help'))
self.action_help.setStatusTip(QCoreApplication.translate('MetaSearch',
'Get Help on MetaSearch'))
self.action_help.triggered.connect(self.help)
self.iface.addPluginToWebMenu(self.web_menu, self.action_help)
# prefab the dialog but not open it yet
self.dialog = MetaSearchDialog(self.iface)
开发者ID:GeoCat,项目名称:QGIS,代码行数:31,代码来源:plugin.py
示例4: __init__
class D3DataVis:
heatmapDialog = None
def __init__(self, iface):
self.iface = iface
def initGui(self):
""" Initialize the menu and dialog boxes for the D3 heatmap chart """
icon = QIcon(os.path.dirname(__file__) + "/icon.png")
self.heatmapAction = QAction(icon, "Circular Date/Time Heatmap", self.iface.mainWindow())
self.heatmapAction.triggered.connect(self.showHeatmapDialog)
self.heatmapAction.setCheckable(False)
self.iface.addWebToolBarIcon(self.heatmapAction)
# Add a D3 Data Visualization menu item to the Web menu
self.iface.addPluginToWebMenu("D3 Data Visualization", self.heatmapAction)
def unload(self):
self.iface.removePluginWebMenu("D3 Data Visualization", self.heatmapAction)
self.iface.removeWebToolBarIcon(self.heatmapAction)
def showHeatmapDialog(self):
"""Display the circular date/time heatmap dialog box"""
if not self.heatmapDialog:
from .heatmapDialog import HeatmapDialog
self.heatmapDialog = HeatmapDialog(self.iface, self.iface.mainWindow())
self.heatmapDialog.show()
开发者ID:NationalSecurityAgency,项目名称:qgis-d3datavis-plugin,代码行数:25,代码来源:d3datavis.py
示例5: build_menu_tree
def build_menu_tree(self):
# Main Menu
self.menu.clear()
self.groups_list = GroupsList()
self.ds_list = DataSourcesList()
data_sources = self.ds_list.data_sources.values()
data_sources = sorted(data_sources, key=lambda x: x.alias or x.id)
ds_hide_list = PluginSettings.get_hide_ds_id_list()
for ds in data_sources:
if ds.id in ds_hide_list:
continue
ds.action.triggered.connect(self.insert_layer)
gr_menu = self.groups_list.get_group_menu(ds.group)
gr_menu.addAction(ds.action)
if gr_menu not in self.menu.children():
self.menu.addMenu(gr_menu)
# QMS web service
self.menu.addSeparator()
self.service_actions.append(self.qms_search_action)
self.menu.addAction(self.qms_search_action)
icon_create_service_path = self.plugin_dir + '/icons/mActionCreate.svg'
qms_create_service_action = QAction(self.tr('Add to Search'), self.iface.mainWindow())
qms_create_service_action.setIcon(QIcon(icon_create_service_path))
qms_create_service_action.triggered.connect(self.openURL)
self.menu.addAction(qms_create_service_action)
# Scales, Settings and About actions
self.menu.addSeparator()
icon_set_nearest_scale_path = self.plugin_dir + '/icons/mActionSettings.svg' # TODO change icon
set_nearest_scale_act = QAction(QIcon(icon_set_nearest_scale_path), self.tr('Set proper scale'), self.iface.mainWindow())
set_nearest_scale_act.triggered.connect(self.set_nearest_scale)
self.menu.addAction(set_nearest_scale_act) # TODO: uncomment after fix
self.service_actions.append(set_nearest_scale_act)
icon_scales_path = self.plugin_dir + '/icons/mActionSettings.svg' # TODO change icon
scales_act = QAction(QIcon(icon_scales_path), self.tr('Set SlippyMap scales'), self.iface.mainWindow())
scales_act.triggered.connect(self.set_tms_scales)
#self.menu.addAction(scales_act) # TODO: uncomment after fix
self.service_actions.append(scales_act)
icon_settings_path = self.plugin_dir + '/icons/mActionSettings.svg'
settings_act = QAction(QIcon(icon_settings_path), self.tr('Settings'), self.iface.mainWindow())
self.service_actions.append(settings_act)
settings_act.triggered.connect(self.show_settings_dialog)
self.menu.addAction(settings_act)
icon_about_path = self.plugin_dir + '/icons/mActionAbout.svg'
info_act = QAction(QIcon(icon_about_path), self.tr('About'), self.iface.mainWindow())
self.service_actions.append(info_act)
info_act.triggered.connect(self.info_dlg.show)
self.menu.addAction(info_act)
开发者ID:nextgis,项目名称:quickmapservices,代码行数:58,代码来源:quick_map_services.py
示例6: registerDatabaseActions
def registerDatabaseActions(self, mainWindow):
Database.registerDatabaseActions(self, mainWindow)
# add a separator
separator = QAction(self)
separator.setSeparator(True)
mainWindow.registerAction(separator, self.tr("&Table"))
action = QAction(self.tr("Run &Vacuum Analyze"), self)
mainWindow.registerAction(action, self.tr("&Table"), self.runVacuumAnalyzeActionSlot)
开发者ID:PeterTFS,项目名称:QGIS,代码行数:10,代码来源:plugin.py
示例7: initGui
def initGui(self):
self.toolbox = ProcessingToolbox()
self.iface.addDockWidget(Qt.RightDockWidgetArea, self.toolbox)
self.toolbox.hide()
self.resultsDock = ResultsDock()
self.iface.addDockWidget(Qt.RightDockWidgetArea, self.resultsDock)
self.resultsDock.hide()
resultsList.resultAdded.connect(self.resultsDock.fillTree)
self.menu = QMenu(self.iface.mainWindow().menuBar())
self.menu.setObjectName('processing')
self.menu.setTitle(self.tr('Pro&cessing'))
self.toolboxAction = self.toolbox.toggleViewAction()
self.toolboxAction.setObjectName('toolboxAction')
self.toolboxAction.setIcon(
QgsApplication.getThemeIcon("/processingAlgorithm.svg"))
self.toolboxAction.setText(self.tr('&Toolbox'))
self.iface.registerMainWindowAction(self.toolboxAction, 'Ctrl+Alt+T')
self.menu.addAction(self.toolboxAction)
self.modelerAction = QAction(
QgsApplication.getThemeIcon("/processingModel.svg"),
self.tr('Graphical &Modeler...'), self.iface.mainWindow())
self.modelerAction.setObjectName('modelerAction')
self.modelerAction.triggered.connect(self.openModeler)
self.iface.registerMainWindowAction(self.modelerAction, 'Ctrl+Alt+M')
self.menu.addAction(self.modelerAction)
self.historyAction = QAction(
QIcon(os.path.join(cmd_folder, 'images', 'history.svg')),
self.tr('&History...'), self.iface.mainWindow())
self.historyAction.setObjectName('historyAction')
self.historyAction.triggered.connect(self.openHistory)
self.iface.registerMainWindowAction(self.historyAction, 'Ctrl+Alt+H')
self.menu.addAction(self.historyAction)
self.resultsAction = self.resultsDock.toggleViewAction()
self.resultsAction.setObjectName('resultsAction')
self.resultsAction.setIcon(
QgsApplication.getThemeIcon("/processingResult.svg"))
self.resultsAction.setText(self.tr('&Results Viewer'))
self.iface.registerMainWindowAction(self.resultsAction, 'Ctrl+Alt+R')
self.menu.addAction(self.resultsAction)
menuBar = self.iface.mainWindow().menuBar()
menuBar.insertMenu(
self.iface.firstRightStandardMenu().menuAction(), self.menu)
self.menu.addSeparator()
initializeMenus()
createMenus()
开发者ID:Jacory,项目名称:QGIS,代码行数:55,代码来源:ProcessingPlugin.py
示例8: QMatplotlibWidget
class QMatplotlibWidget(QWidget):
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.canvas = QMatplotlibCanvas()
self.ax = self.canvas.ax
self.figure = self.canvas.figure
self.toolBar = NavigationToolbar2QT(self.canvas, self)
bgColor = self.palette().color(QPalette.Background).name()
self.figure.set_facecolor(bgColor)
self.layout = QVBoxLayout()
self.layout.setSpacing(2)
self.layout.setMargin(0)
self.layout.addWidget(self.toolBar)
self.layout.addWidget(self.canvas)
self.setLayout(self.layout)
self._setupToolbar()
def _setupToolbar(self):
self.actionToggleGrid = QAction(self.tr('Toggle grid'), self.toolBar)
self.actionToggleGrid.setIcon(
QIcon(os.path.join(pluginPath, 'icons', 'toggleGrid.svg')))
self.actionToggleGrid.setCheckable(True)
self.actionToggleGrid.triggered.connect(self.toggleGrid)
self.toolBar.insertAction(self.toolBar.actions()[7], self.actionToggleGrid)
self.toolBar.insertSeparator(self.toolBar.actions()[8])
def toggleGrid(self):
self.ax.grid()
self.canvas.draw()
def alignLabels(self):
self.figure.autofmt_xdate()
def clear(self):
self.ax.clear()
self.canvas.draw()
def setTitle(self, text):
self.ax.set_title(text)
def setXAxisCaption(self, text):
self.ax.set_xlabel(text)
def setYAxisCaption(self, text):
self.ax.set_ylabel(text)
开发者ID:alexbruy,项目名称:qscatter,代码行数:52,代码来源:qmatplotlibwidget.py
示例9: menu
def menu(self):
menu = QMenu()
refreshAction = QAction(icon("refresh.svg"), "Refresh", menu)
refreshAction.triggered.connect(self.refreshContent)
menu.addAction(refreshAction)
createBranchAction = QAction(icon("create_branch.png"), "Create branch", menu)
createBranchAction.triggered.connect(self.createBranch)
menu.addAction(createBranchAction)
deleteAction = QAction(QgsApplication.getThemeIcon('/mActionDeleteSelected.svg'), "Delete", menu)
deleteAction.triggered.connect(self.delete)
menu.addAction(deleteAction)
deleteAction.setEnabled(self.parent().childCount() > 1 and self.branch != "master")
return menu
开发者ID:boundlessgeo,项目名称:qgis-geogiglight-plugin,代码行数:13,代码来源:navigatordialog.py
示例10: setAsNonRepoLayer
def setAsNonRepoLayer(layer):
removeLayerActions(layer)
action = QAction("Import to GeoGig...", config.iface.legendInterface())
action.triggered.connect(partial(addLayer, layer))
if layer.type() == QgsMapLayer.RasterLayer or layer.storageType() != 'GPKG':
action.setEnabled(False)
config.iface.legendInterface().addLegendLayerAction(action, u"GeoGig", u"id2", QgsMapLayer.VectorLayer, False)
config.iface.legendInterface().addLegendLayerActionForLayer(action, layer)
_actions[layer.id()] = [action]
try:
repoWatcher.layerUpdated.disconnect(updateInfoActions)
except:
pass #In case it is a layer that was never a repo layer
开发者ID:boundlessgeo,项目名称:qgis-geogiglight-plugin,代码行数:13,代码来源:layeractions.py
示例11: selectOutput
def selectOutput(self):
if isinstance(self.parameter, QgsProcessingParameterFolderDestination):
self.selectDirectory()
else:
popupMenu = QMenu()
if not self.default_selection:
if self.parameter.flags() & QgsProcessingParameterDefinition.FlagOptional:
actionSkipOutput = QAction(
self.tr('Skip Output'), self.btnSelect)
actionSkipOutput.triggered.connect(self.skipOutput)
popupMenu.addAction(actionSkipOutput)
if isinstance(self.parameter, QgsProcessingParameterFeatureSink) \
and self.parameter.supportsNonFileBasedOutput():
# use memory layers for temporary layers if supported
actionSaveToTemp = QAction(
self.tr('Create Temporary Layer'), self.btnSelect)
else:
actionSaveToTemp = QAction(
self.tr('Save to a Temporary File'), self.btnSelect)
actionSaveToTemp.triggered.connect(self.saveToTemporary)
popupMenu.addAction(actionSaveToTemp)
actionSaveToFile = QAction(
QCoreApplication.translate('DestinationSelectionPanel', 'Save to File…'), self.btnSelect)
actionSaveToFile.triggered.connect(self.selectFile)
popupMenu.addAction(actionSaveToFile)
if isinstance(self.parameter, QgsProcessingParameterFeatureSink) \
and self.parameter.supportsNonFileBasedOutput():
actionSaveToGpkg = QAction(
QCoreApplication.translate('DestinationSelectionPanel', 'Save to GeoPackage…'), self.btnSelect)
actionSaveToGpkg.triggered.connect(self.saveToGeopackage)
popupMenu.addAction(actionSaveToGpkg)
actionSaveToPostGIS = QAction(
QCoreApplication.translate('DestinationSelectionPanel', 'Save to PostGIS Table…'), self.btnSelect)
actionSaveToPostGIS.triggered.connect(self.saveToPostGIS)
settings = QgsSettings()
settings.beginGroup('/PostgreSQL/connections/')
names = settings.childGroups()
settings.endGroup()
actionSaveToPostGIS.setEnabled(bool(names))
popupMenu.addAction(actionSaveToPostGIS)
actionSetEncoding = QAction(
QCoreApplication.translate('DestinationSelectionPanel', 'Change File Encoding ({})…').format(self.encoding), self.btnSelect)
actionSetEncoding.triggered.connect(self.selectEncoding)
popupMenu.addAction(actionSetEncoding)
popupMenu.exec_(QCursor.pos())
开发者ID:lbartoletti,项目名称:QGIS,代码行数:51,代码来源:DestinationSelectionPanel.py
示例12: selectOutput
def selectOutput(self):
if isinstance(self.parameter, QgsProcessingParameterFolderDestination):
self.selectDirectory()
else:
popupMenu = QMenu()
if self.parameter.flags() & QgsProcessingParameterDefinition.FlagOptional:
actionSkipOutput = QAction(
self.tr('Skip output'), self.btnSelect)
actionSkipOutput.triggered.connect(self.skipOutput)
popupMenu.addAction(actionSkipOutput)
if isinstance(self.parameter, QgsProcessingParameterFeatureSink) \
and self.alg.provider().supportsNonFileBasedOutput():
# use memory layers for temporary layers if supported
actionSaveToTemp = QAction(
self.tr('Create temporary layer'), self.btnSelect)
else:
actionSaveToTemp = QAction(
self.tr('Save to a temporary file'), self.btnSelect)
actionSaveToTemp.triggered.connect(self.saveToTemporary)
popupMenu.addAction(actionSaveToTemp)
actionSaveToFile = QAction(
self.tr('Save to file...'), self.btnSelect)
actionSaveToFile.triggered.connect(self.selectFile)
popupMenu.addAction(actionSaveToFile)
actionShowExpressionsBuilder = QAction(
self.tr('Use expression...'), self.btnSelect)
actionShowExpressionsBuilder.triggered.connect(self.showExpressionsBuilder)
popupMenu.addAction(actionShowExpressionsBuilder)
if isinstance(self.parameter, QgsProcessingParameterFeatureSink) \
and self.alg.provider().supportsNonFileBasedOutput():
actionSaveToSpatialite = QAction(
self.tr('Save to SpatiaLite table...'), self.btnSelect)
actionSaveToSpatialite.triggered.connect(self.saveToSpatialite)
popupMenu.addAction(actionSaveToSpatialite)
actionSaveToPostGIS = QAction(
self.tr('Save to PostGIS table...'), self.btnSelect)
actionSaveToPostGIS.triggered.connect(self.saveToPostGIS)
settings = QgsSettings()
settings.beginGroup('/PostgreSQL/connections/')
names = settings.childGroups()
settings.endGroup()
actionSaveToPostGIS.setEnabled(bool(names))
popupMenu.addAction(actionSaveToPostGIS)
popupMenu.exec_(QCursor.pos())
开发者ID:timlinux,项目名称:QGIS,代码行数:50,代码来源:DestinationSelectionPanel.py
示例13: __init__
class DBManagerPlugin:
def __init__(self, iface):
self.iface = iface
self.dlg = None
def initGui(self):
self.action = QAction(QIcon(":/db_manager/icon"), QApplication.translate("DBManagerPlugin", "DB Manager"),
self.iface.mainWindow())
self.action.setObjectName("dbManager")
self.action.triggered.connect(self.run)
# Add toolbar button and menu item
if hasattr(self.iface, 'addDatabaseToolBarIcon'):
self.iface.addDatabaseToolBarIcon(self.action)
else:
self.iface.addToolBarIcon(self.action)
if hasattr(self.iface, 'addPluginToDatabaseMenu'):
self.iface.addPluginToDatabaseMenu(QApplication.translate("DBManagerPlugin", "DB Manager"), self.action)
else:
self.iface.addPluginToMenu(QApplication.translate("DBManagerPlugin", "DB Manager"), self.action)
def unload(self):
# Remove the plugin menu item and icon
if hasattr(self.iface, 'removePluginDatabaseMenu'):
self.iface.removePluginDatabaseMenu(QApplication.translate("DBManagerPlugin", "DB Manager"), self.action)
else:
self.iface.removePluginMenu(QApplication.translate("DBManagerPlugin", "DB Manager"), self.action)
if hasattr(self.iface, 'removeDatabaseToolBarIcon'):
self.iface.removeDatabaseToolBarIcon(self.action)
else:
self.iface.removeToolBarIcon(self.action)
if self.dlg is not None:
self.dlg.close()
def run(self):
# keep opened only one instance
if self.dlg is None:
from .db_manager import DBManager
self.dlg = DBManager(self.iface)
self.dlg.destroyed.connect(self.onDestroyed)
self.dlg.show()
self.dlg.raise_()
self.dlg.setWindowState(self.dlg.windowState() & ~Qt.WindowMinimized)
self.dlg.activateWindow()
def onDestroyed(self, obj):
self.dlg = None
开发者ID:AM7000000,项目名称:QGIS,代码行数:49,代码来源:db_manager_plugin.py
示例14: __init__
def __init__(self, parent=None):
QTableView.__init__(self, parent)
self.setSelectionBehavior(QAbstractItemView.SelectRows)
self.setSelectionMode(QAbstractItemView.ExtendedSelection)
self.item = None
self.dirty = False
# allow copying results
copyAction = QAction(QApplication.translate("DBManagerPlugin", "Copy"), self)
self.addAction(copyAction)
copyAction.setShortcuts(QKeySequence.Copy)
copyAction.triggered.connect(self.copySelectedResults)
self._clear()
开发者ID:AlisterH,项目名称:Quantum-GIS,代码行数:15,代码来源:table_viewer.py
示例15: addAlgorithmEntry
def addAlgorithmEntry(alg, menuName, submenuName, actionText=None, icon=None, addButton=False):
action = QAction(icon or alg.icon(), actionText or alg.displayName(), iface.mainWindow())
action.triggered.connect(lambda: _executeAlgorithm(alg))
action.setObjectName("mProcessingUserMenu_%s" % alg.id())
if menuName:
menu = getMenu(menuName, iface.mainWindow().menuBar())
submenu = getMenu(submenuName, menu)
submenu.addAction(action)
if addButton:
global algorithmsToolbar
if algorithmsToolbar is None:
algorithmsToolbar = iface.addToolBar('ProcessingAlgorithms')
algorithmsToolbar.addAction(action)
开发者ID:ndavid,项目名称:QGIS,代码行数:15,代码来源:menus.py
示例16: initGui
def initGui(self):
# Create the menu items in the Plugin menu and attach the icon to the toolbar
icon = QIcon(os.path.dirname(__file__) + "/icon.png")
self.searchAction = QAction(icon, "Search Layers", self.iface.mainWindow())
self.searchAction.setObjectName('searchLayers')
self.searchAction.triggered.connect(self.showSearchDialog)
self.iface.addToolBarIcon(self.searchAction)
self.iface.addPluginToMenu("Search Layers", self.searchAction)
# Help
icon = QIcon(os.path.dirname(__file__) + '/help.png')
self.helpAction = QAction(icon, "Help", self.iface.mainWindow())
self.helpAction.setObjectName('searchLayersHelp')
self.helpAction.triggered.connect(self.help)
self.iface.addPluginToMenu('Search Layers', self.helpAction)
开发者ID:NationalSecurityAgency,项目名称:qgis-layersearch-plugin,代码行数:15,代码来源:searchLayers.py
示例17: initGui
def initGui(self):
self.actionRun = QAction(self.tr("Statist"), self.iface.mainWindow())
self.actionRun.setIcon(QIcon(os.path.join(pluginPath, "icons", "statist.png")))
self.actionRun.setObjectName("runStatist")
self.iface.registerMainWindowAction(self.actionRun, "Shift+S")
self.actionAbout = QAction(self.tr("About Statist…"), self.iface.mainWindow())
self.actionAbout.setIcon(QgsApplication.getThemeIcon("/mActionHelpContents.svg"))
self.actionRun.setObjectName("aboutStatist")
self.iface.addPluginToVectorMenu(self.tr("Statist"), self.actionRun)
self.iface.addPluginToVectorMenu(self.tr("Statist"), self.actionAbout)
self.iface.addVectorToolBarIcon(self.actionRun)
self.actionRun.triggered.connect(self.run)
self.actionAbout.triggered.connect(self.about)
开发者ID:alexbruy,项目名称:statist,代码行数:16,代码来源:statistplugin.py
示例18: __init__
class Send2GE:
def __init__(self, iface):
"""Initialize class"""
# save reference to QGIS interface
self.iface = iface
self.plugin_dir = get_file_dir(__file__)
def initGui(self):
"""Initialize graphic user interface"""
#create action that will be run by the plugin
self.action = QAction(
QIcon("%s/icons/cursor2.png" % self.plugin_dir),
"Send to Google Earth",
self.iface.mainWindow()
)
self.action.setWhatsThis("Send to Google Earth")
self.action.setStatusTip("Send coordinates of a mouse click to Google Earth")
# add plugin menu to Vector toolbar
self.iface.addPluginToMenu("Send2GoogleEarth",self.action)
# add icon to new menu item in Vector toolbar
self.iface.addToolBarIcon(self.action)
# connect action to the run method
self.action.triggered.connect(self.run)
# prepare map tool
self.mapTool = Send2GEtool(self.iface)
#self.iface.mapCanvas().mapToolSet.connect(self.mapToolChanged)
def unload(self):
"""Actions to run when the plugin is unloaded"""
# remove menu and icon from the menu
self.iface.removeToolBarIcon(self.action)
self.iface.removePluginMenu("Send2GoogleEarth",self.action)
if self.iface.mapCanvas().mapTool() == self.mapTool:
self.iface.mapCanvas().unsetMapTool(self.mapTool)
del self.mapTool
def run(self):
"""Action to run"""
# create a string and show it
self.iface.mapCanvas().setMapTool(self.mapTool)
开发者ID:nextgis,项目名称:send2google_earth,代码行数:47,代码来源:send2google_earth.py
示例19: __init__
class QConsolidatePlugin:
def __init__(self, iface):
self.iface = iface
locale = QgsApplication.locale()
qmPath = '{}/i18n/qconsolidate_{}.qm'.format(pluginPath, locale)
if os.path.exists(qmPath):
self.translator = QTranslator()
self.translator.load(qmPath)
QCoreApplication.installTranslator(self.translator)
def initGui(self):
self.actionRun = QAction(self.tr('QConsolidate'), self.iface.mainWindow())
self.actionRun.setIcon(QIcon(os.path.join(pluginPath, 'icons', 'qconsolidate.svg')))
self.actionRun.setObjectName('runQConsolidate')
self.actionAbout = QAction(self.tr('About QConsolidate…'), self.iface.mainWindow())
self.actionAbout.setIcon(QgsApplication.getThemeIcon('/mActionHelpContents.svg'))
self.actionRun.setObjectName('aboutQConsolidate')
self.iface.addPluginToMenu(self.tr('QConsolidate'), self.actionRun)
self.iface.addPluginToMenu(self.tr('QConsolidate'), self.actionAbout)
self.iface.addToolBarIcon(self.actionRun)
self.actionRun.triggered.connect(self.run)
self.actionAbout.triggered.connect(self.about)
self.taskManager = QgsApplication.taskManager()
def unload(self):
self.iface.removePluginMenu(self.tr('QConsolidate'), self.actionRun)
self.iface.removePluginMenu(self.tr('QConsolidate'), self.actionAbout)
self.iface.removeToolBarIcon(self.actionRun)
def run(self):
dlg = QConsolidateDialog()
if dlg.exec_():
task = dlg.task()
task.consolidateComplete.connect(self.completed)
task.errorOccurred.connect(self.errored)
self.taskManager.addTask(task)
def about(self):
d = AboutDialog()
d.exec_()
def tr(self, text):
return QCoreApplication.translate('QConsolidate', text)
def completed(self):
self.iface.messageBar().pushSuccess(self.tr('QConsolidate'), self.tr('Project consolidated successfully.'))
def errored(self, error):
self.iface.messageBar().pushWarning(self.tr('QConsolidate'), error)
开发者ID:alexbruy,项目名称:qconsolidate,代码行数:56,代码来源:qconsolidateplugin.py
示例20: initGui
def initGui(self):
self.actionRun = QAction(self.tr('QConsolidate'), self.iface.mainWindow())
self.actionRun.setIcon(QIcon(os.path.join(pluginPath, 'icons', 'qconsolidate.svg')))
self.actionRun.setObjectName('runQConsolidate')
self.actionAbout = QAction(self.tr('About QConsolidate…'), self.iface.mainWindow())
self.actionAbout.setIcon(QgsApplication.getThemeIcon('/mActionHelpContents.svg'))
self.actionRun.setObjectName('aboutQConsolidate')
self.iface.addPluginToMenu(self.tr('QConsolidate'), self.actionRun)
self.iface.addPluginToMenu(self.tr('QConsolidate'), self.actionAbout)
self.iface.addToolBarIcon(self.actionRun)
self.actionRun.triggered.connect(self.run)
self.actionAbout.triggered.connect(self.about)
self.taskManager = QgsApplication.taskManager()
开发者ID:alexbruy,项目名称:qconsolidate,代码行数:17,代码来源:qconsolidateplugin.py
注:本文中的qgis.PyQt.QtWidgets.QAction类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论