本文整理汇总了Python中qgis.PyQt.QtWidgets.QAction.setWhatsThis方法的典型用法代码示例。如果您正苦于以下问题:Python QAction.setWhatsThis方法的具体用法?Python QAction.setWhatsThis怎么用?Python QAction.setWhatsThis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.PyQt.QtWidgets.QAction
的用法示例。
在下文中一共展示了QAction.setWhatsThis方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from qgis.PyQt.QtWidgets import QAction [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QAction import setWhatsThis [as 别名]
class QScatterPlugin:
def __init__(self, iface):
self.iface = iface
overrideLocale = QSettings().value('locale/overrideFlag', False, bool)
if not overrideLocale:
locale = QLocale.system().name()[:2]
else:
locale = QSettings().value('locale/userLocale', '')
qmPath = '{}/i18n/qscatter_{}.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('QScatter'), self.iface.mainWindow())
self.actionRun.setIcon(
QIcon(os.path.join(pluginPath, 'icons', 'qscatter.svg')))
self.actionRun.setWhatsThis(
self.tr('Interactive scatter plot'))
self.actionRun.setObjectName('runQScatter')
self.actionAbout = QAction(
self.tr('About...'), self.iface.mainWindow())
self.actionAbout.setIcon(
QgsApplication.getThemeIcon('/mActionHelpContents.svg'))
self.actionAbout.setWhatsThis(self.tr('About QScatter'))
self.actionRun.setObjectName('aboutQScatter')
self.iface.addPluginToVectorMenu(
self.tr('QScatter'), self.actionRun)
self.iface.addPluginToVectorMenu(
self.tr('QScatter'), self.actionAbout)
self.iface.addVectorToolBarIcon(self.actionRun)
self.actionRun.triggered.connect(self.run)
self.actionAbout.triggered.connect(self.about)
def unload(self):
self.iface.removePluginVectorMenu(
self.tr('QScatter'), self.actionRun)
self.iface.removePluginVectorMenu(
self.tr('QScatter'), self.actionAbout)
self.iface.removeVectorToolBarIcon(self.actionRun)
def run(self):
dlg = QScatterDialog(self.iface)
dlg.show()
dlg.exec_()
def about(self):
dlg = AboutDialog()
dlg.exec_()
def tr(self, text):
return QCoreApplication.translate('QScatter', text)
示例2: add_action
# 需要导入模块: from qgis.PyQt.QtWidgets import QAction [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QAction import setWhatsThis [as 别名]
def add_action(
self,
icon_path,
text,
callback,
enabled_flag=True,
add_to_menu=True,
add_to_toolbar=True,
status_tip=None,
whats_this=None,
parent=None
):
"""Add a toolbar icon to the toolbar."""
icon = QIcon(icon_path)
action = QAction(icon, text, parent)
action.triggered.connect(callback)
action.setEnabled(enabled_flag)
if status_tip is not None:
action.setStatusTip(status_tip)
if whats_this is not None:
action.setWhatsThis(whats_this)
if add_to_toolbar:
self.toolbar.addAction(action)
if add_to_menu:
self.iface.addPluginToMenu(self.menu, action)
self.actions.append(action)
return action
示例3: __init__
# 需要导入模块: from qgis.PyQt.QtWidgets import QAction [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QAction import setWhatsThis [as 别名]
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)
示例4: add_action
# 需要导入模块: from qgis.PyQt.QtWidgets import QAction [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QAction import setWhatsThis [as 别名]
def add_action(
self,
icon_path,
text,
callback,
enabled_flag=True,
checkable=False,
add_to_menu=True,
add_to_toolbar=True,
status_tip=None,
whats_this=None,
menu=None,
parent=None):
icon = QIcon(icon_path)
action = QAction(icon, text, parent)
action.triggered.connect(callback)
action.setEnabled(enabled_flag)
action.setCheckable(checkable)
if status_tip is not None:
action.setStatusTip(status_tip)
if whats_this is not None:
action.setWhatsThis(whats_this)
if menu is not None:
action.setMenu(menu)
if add_to_toolbar:
self.toolbar.addAction(action)
if add_to_menu:
self.iface.addPluginToVectorMenu(
self.menu,
action)
self.actions.append(action)
return action
示例5: MetaSearchPlugin
# 需要导入模块: from qgis.PyQt.QtWidgets import QAction [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QAction import setWhatsThis [as 别名]
class MetaSearchPlugin(object):
"""base plugin"""
def __init__(self, iface):
"""init"""
self.iface = iface
self.context = StaticContext()
self.action_run = None
self.action_help = None
self.dialog = None
self.web_menu = '&MetaSearch'
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)
def unload(self):
"""teardown"""
# remove the plugin menu item and icon
self.iface.removePluginWebMenu(self.web_menu, self.action_run)
self.iface.removePluginWebMenu(self.web_menu, self.action_help)
self.iface.removeWebToolBarIcon(self.action_run)
def run(self):
"""open MetaSearch"""
self.dialog.exec_()
def help(self):
"""open help in user's default web browser"""
open_url(get_help_url())
示例6: PdokServicesPlugin
# 需要导入模块: from qgis.PyQt.QtWidgets import QAction [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QAction import setWhatsThis [as 别名]
#.........这里部分代码省略.........
# self.dlg.radioDocked.setChecked(True)
# # docked the dialog is immidiately visible, so should run NOW
# else:
# self.run_action.triggered.connect(self.run)
# self.dlg.radioDocked.setChecked(False)
# self.setupfq()
self.run_action.triggered.connect(self.run)
#self.dlg.radioDocked.setChecked(False)
self.setupfq()
# Add toolbar button and menu item
#self.iface.addToolBarIcon(self.action)
self.toolbar = self.iface.addToolBar("PDOK services plugin")
self.toolbar.setObjectName("PDOK services plugin")
self.toolbar.addAction(self.run_action)
self.toolbarSearch = QLineEdit()
self.toolbarSearch.setMaximumWidth(200)
self.toolbarSearch.setAlignment(Qt.AlignLeft)
self.toolbarSearch.setPlaceholderText("PDOK Locatieserver zoek")
self.toolbar.addWidget(self.toolbarSearch)
self.toolbarSearch.returnPressed.connect(self.searchAddressFromToolbar)
# address/point cleanup
self.clean_action = QAction(QIcon(":/plugins/pdokservicesplugin/eraser.png"), \
u"Cleanup", self.eraseAddress())
self.toolbar.addAction(self.clean_action)
self.clean_action.triggered.connect(self.eraseAddress)
self.iface.addPluginToMenu(u"&Pdok Services Plugin", self.run_action)
# about
self.aboutAction = QAction(QIcon(":/plugins/pdokservicesplugin/help.png"), \
"About", self.iface.mainWindow())
self.aboutAction.setWhatsThis("Pdok Services Plugin About")
self.iface.addPluginToMenu(u"&Pdok Services Plugin", self.aboutAction)
self.aboutAction.triggered.connect(self.about)
self.dlg.ui.btnLoadLayer.clicked.connect(self.loadService)
self.dlg.geocoderSearch.returnPressed.connect(self.searchAddress)
self.dlg.geocoderSearch.textEdited.connect(self.searchAddress)
self.dlg.geocoderSearch.setPlaceholderText("PDOK Locatieserver zoek, bv postcode of postcode huisnummer")
self.dlg.geocoderResultSearch.textChanged.connect(self.filterGeocoderResult)
self.dlg.geocoderResultSearch.setPlaceholderText("een of meer zoekwoorden uit resultaat")
#self.dlg.radioDocked.toggled.connect(self.set_docked)
self.dlg.btnCheckPdokJson.clicked.connect(self.checkPdokJson)
#self.iface.mapCanvas().renderStarting.connect(self.extentsChanged)
ui = self.dlg.ui
cbxs = [ui.cbx_gem, ui.cbx_wpl, ui.cbx_weg, ui.cbx_pcd, ui.cbx_adr, ui.cbx_pcl, ui.cbx_hmp]
# connect all fq checkboxes with suggest, so upon a change in fq filter we re-search
for cbx in cbxs:
cbx.stateChanged.connect(self.searchAddress)
self.run(True)
# for now hiding the pointer as soon as the extent changes
#def extentsChanged(self):
# self.removePointer()
def checkPdokJson(self):
myversion = self.getSettingsValue('pdokversion', '1')
示例7: create_action
# 需要导入模块: from qgis.PyQt.QtWidgets import QAction [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QAction import setWhatsThis [as 别名]
def create_action(
icon_path,
text,
callback,
enabled_flag=True,
status_tip=None,
whats_this=None,
parent=None,
object_name=None):
"""
# adapted from RedLayers by E. Ferreguti
Create an action.
:param icon_path: Path to the icon for this action. Can be a resource
path (e.g. ':/plugins/foo/bar.png') or a normal file system path.
:type icon_path: str
:param text: Text that should be shown in menu items for this action.
:type text: str
:param callback: Function to be called when the action is triggered.
:type callback: function
:param enabled_flag: A flag indicating if the action should be enabled
by default. Defaults to True.
:type enabled_flag: bool
:param status_tip: Optional text to show in a popup when mouse pointer
hovers over the action.
:type status_tip: str
:param parent: Parent widget for the new action. Defaults None.
:type parent: QWidget
:param whats_this: Optional text to show in the status bar when the
mouse pointer hovers over the action.
:param object_name: Optional name to identify objects during customization
:type object_name: str
:returns: The action that was created.
:rtype: QAction
"""
icon = QIcon(icon_path)
action = QAction(icon, text, parent)
if callback:
action.triggered.connect(callback)
action.setEnabled(enabled_flag)
if status_tip:
action.setStatusTip(status_tip)
if whats_this:
action.setWhatsThis(whats_this)
if object_name:
action.setObjectName(object_name)
return action
示例8: ImpEpanet
# 需要导入模块: from qgis.PyQt.QtWidgets import QAction [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QAction import setWhatsThis [as 别名]
class ImpEpanet(object):
def __init__(self, iface):
# Save a reference to the QGIS iface
self.iface = iface
self.canvas = self.iface.mapCanvas()
self.dlg = ExportEpanetInpFilesDialog()
self.sections = ['junctions', 'tanks', 'pipes', 'pumps', 'reservoirs', 'valves', 'STATUS', 'PATTERNS', 'CURVES',
'CONTROLS', 'RULES', 'ENERGY', 'REACTIONS', 'REACTIONS_I', 'EMITTERS', 'QUALITY', 'SOURCES',
'MIXING', 'TIMES', 'REPORT', 'OPTIONS']
def initGui(self):
# Create action
sys.path.append(os.path.dirname(__file__)+'/impcount.py')
self.action = QAction(QIcon(":/plugins/ImportEpanetInpFiles/impepanet.png"), "Import Epanet Input File",
self.iface.mainWindow())
self.action.setWhatsThis("Import Epanet Input File")
self.action.triggered.connect(self.run)
self.iface.addToolBarIcon(self.action)
self.iface.addPluginToMenu("&ImportEpanetInpFiles", self.action)
self.actionexp = QAction(QIcon(":/plugins/ImportEpanetInpFiles/expepanet.png"), "Export Epanet Input File",
self.iface.mainWindow())
self.actionexp.setWhatsThis("Export Epanet Input File")
self.actionexp.triggered.connect(self.runexp)
self.iface.addToolBarIcon(self.actionexp)
self.iface.addPluginToMenu("&ImportEpanetInpFiles", self.actionexp)
self.dlg.ok_button.clicked.connect(self.ok)
self.dlg.cancel_button.clicked.connect(self.cancel)
self.dlg.toolButtonOut.clicked.connect(self.toolButtonOut)
def unload(self):
# Remove the plugin
self.iface.removePluginMenu("&ImportEpanetInpFiles", self.action)
self.iface.removeToolBarIcon(self.action)
self.iface.removePluginMenu("&ImportEpanetInpFiles", self.actionexp)
self.iface.removeToolBarIcon(self.actionexp)
def run(self):
filePath = QFileDialog.getOpenFileName(self.iface.mainWindow(), "Choose EPANET Input file",
os.path.join(os.path.join(os.path.expanduser('~')), 'Desktop'),
"Epanet Inp File (*.inp)")
if filePath[0] == "":
return
epa2gis(filePath[0])
self.iface.messageBar().clearWidgets()
msgBox = QMessageBox()
msgBox.setWindowTitle('ImportEpanetInpFiles')
msgBox.setText('Shapefiles have been created successfully in folder "_shapefiles_".')
msgBox.exec_()
def runexp(self):
self.dlg.out.setText('')
self.layers = self.canvas.layers()
self.layer_list = []
self.layer_list = ['NONE']
[self.layer_list.append(layer.name()) for layer in self.layers]
for sect in self.sections:
eval('self.dlg.sect_' + sect + '.clear()')
eval('self.dlg.sect_' + sect + '.addItems(self.layer_list)')
indices = [i for i, s in enumerate(self.layer_list) if sect in s]
if indices:
if sect == 'REACTIONS':
eval('self.dlg.sect_' + sect + '.setCurrentIndex(indices[1])')
else:
eval('self.dlg.sect_' + sect + '.setCurrentIndex(indices[0])')
self.dlg.setWindowFlags(Qt.CustomizeWindowHint | Qt.WindowStaysOnTopHint | Qt.WindowCloseButtonHint)
self.dlg.show()
def cancel(self):
self.layer_list = []
self.layer_list = ['NONE']
for sect in self.sections:
exec ('self.dlg.sect_' + sect + '.clear()')
self.dlg.close()
def toolButtonOut(self):
self.outEpanetName = QFileDialog.getSaveFileName(None, 'Save File',
os.path.join(os.path.join(os.path.expanduser('~')),
'Desktop'), 'Epanet Inp File (*.inp)')
self.dlg.out.setText(self.outEpanetName[0])
def selectOutp(self):
msgBox = QMessageBox()
msgBox.setIcon(QMessageBox.Warning)
msgBox.setWindowTitle('Warning')
msgBox.setText('Please define Epanet Inp File location.')
msgBox.setWindowFlags(Qt.CustomizeWindowHint | Qt.WindowStaysOnTopHint | Qt.WindowCloseButtonHint)
msgBox.exec_()
return True
def ok(self):
# Here check if select OK button, get the layer fields
# Initialize
# [JUNCTIONS]
if self.dlg.out.text() == '':
#.........这里部分代码省略.........
示例9: BoundlessConnectPlugin
# 需要导入模块: from qgis.PyQt.QtWidgets import QAction [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QAction import setWhatsThis [as 别名]
class BoundlessConnectPlugin(object):
def __init__(self, iface):
self.iface = iface
try:
from boundlessconnect.tests import testerplugin
from qgistester.tests import addTestModule
addTestModule(testerplugin, 'Boundless Connect')
except Exception as e:
pass
self.dockWidget = None
readSettings()
self.iface.initializationCompleted.connect(self.checkFirstRun)
def initGui(self):
self.dockWidget = getConnectDockWidget()
self.iface.addDockWidget(Qt.RightDockWidgetArea, self.dockWidget)
self.dockWidget.hide()
utils.setRepositoryUrl()
self.actionRunWizard = self.dockWidget.toggleViewAction()
self.actionRunWizard.setText('Boundless Connect')
self.actionRunWizard.setIcon(
QIcon(os.path.join(pluginPath, 'icons', 'connect.svg')))
self.actionRunWizard.setWhatsThis('Boundless Connect')
self.actionRunWizard.setObjectName('actionRunWizard')
# If Boundless repository is a directory, add menu entry
# to start modified Plugin Manager which works with local repositories
if utils.isRepositoryInDirectory():
self.actionPluginManager = QAction(
'Manage plugins (local folder)', self.iface.mainWindow())
self.actionPluginManager.setIcon(
QIcon(os.path.join(pluginPath, 'icons', 'plugin.svg')))
self.actionPluginManager.setWhatsThis(
'Manage and install plugins from local repository')
self.actionPluginManager.setObjectName('actionPluginManager')
self.iface.addPluginToMenu(
'Boundless Connect', self.actionPluginManager)
self.actionPluginManager.triggered.connect(self.pluginManagerLocal)
actions = self.iface.mainWindow().menuBar().actions()
for action in actions:
if action.menu().objectName() == 'mPluginMenu':
menuPlugin = action.menu()
separator = menuPlugin.actions()[1]
menuPlugin.insertAction(separator, self.actionRunWizard)
if utils.isRepositoryInDirectory():
menuPlugin.insertAction(separator, self.actionPluginManager)
addSettingsMenu('Boundless Connect')
addHelpMenu('Boundless Connect')
addAboutMenu('Boundless Connect')
# Enable check for updates if it is not enabled
utils.addCheckForUpdates()
try:
from lessons import addLessonsFolder, addGroup
folder = os.path.join(os.path.dirname(__file__), "_lessons")
addLessonsFolder(folder, "boundlessconnect")
group_description = os.path.join(folder, "group.md")
addGroup("Boundless Connect plugin", group_description)
except:
pass
def unload(self):
actions = self.iface.mainWindow().menuBar().actions()
for action in actions:
if action.menu().objectName() == 'mPluginMenu':
menuPlugin = action.menu()
menuPlugin.removeAction(self.actionRunWizard)
if utils.isRepositoryInDirectory():
menuPlugin.removeAction(self.actionPluginManager)
removeSettingsMenu('Boundless Connect')
removeHelpMenu('Boundless Connect')
removeAboutMenu('Boundless Connect')
self.dockWidget.hide()
try:
from boundlessconnect.tests import testerplugin
from qgistester.tests import removeTestModule
removeTestModule(testerplugin, 'Boundless Connect')
except Exception as e:
pass
try:
from lessons import removeLessonsFolder
folder = os.path.join(pluginPath, '_lessons')
removeLessonsFolder(folder)
except:
pass
#.........这里部分代码省略.........
示例10: __init__
# 需要导入模块: from qgis.PyQt.QtWidgets import QAction [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QAction import setWhatsThis [as 别名]
class PostNAS_Search:
def __init__(self, iface):
# Save reference to the QGIS interface
self.iface = iface
# initialize plugin directory
self.plugin_dir = os.path.dirname(__file__)
# initialize locale
locale = QSettings().value('locale/userLocale')[0:2]
locale_path = os.path.join(self.plugin_dir,'i18n','PostNAS_Search_{}.qm'.format(locale))
if os.path.exists(locale_path):
self.translator = QTranslator()
self.translator.load(locale_path)
if qVersion() > '4.3.3':
QCoreApplication.installTranslator(self.translator)
# Create the dialog (after translation) and keep reference
self.dlg = PostNAS_SearchDialog(iface=self.iface)
self.conf = PostNAS_ConfDialog(iface=self.iface)
# Declare instance attributes
self.actions = []
self.menu = self.tr(u'&PostNAS_Search')
self.searchDockWidget = None
self.searchDockWidgetArea = Qt.LeftDockWidgetArea
# noinspection PyMethodMayBeStatic
def tr(self, message):
# noinspection PyTypeChecker,PyArgumentList,PyCallByClass
return QCoreApplication.translate('PostNAS_Search', message)
def initGui(self):
# Create Conf-Action and Menuentry
self.confAction = QAction("Einstellungen", self.iface.mainWindow())
self.confAction.setWhatsThis("Konfiguration der PostNAS-Suche")
self.confAction.setStatusTip("Konfiguration der PostNAS-Suche")
self.confAction.triggered.connect(self.showConf)
if hasattr(self.iface, "addPluginToDatabaseMenu"):
self.iface.addPluginToDatabaseMenu("&PostNAS-Suche", self.confAction)
else:
self.iface.addPluginToMenu("&PostNAS-Suche", self.confAction)
self.toggleSearchAction = QAction(u"Flurstücksuche", self.iface.mainWindow())
self.toggleSearchAction.setWhatsThis(u"Starten/Schliessen der Flurstücksuche")
self.toggleSearchAction.setStatusTip(u"Starten/Schliessen der Flurstücksuche")
self.toggleSearchAction.triggered.connect(self.toggleWidget)
if hasattr(self.iface, "addPluginToDatabaseMenu"):
self.iface.addPluginToDatabaseMenu("&PostNAS-Suche", self.toggleSearchAction)
else:
self.iface.addPluginToMenu("&PostNAS-Suche", self.toggleSearchAction)
self.fulltextindex = QAction(u"Volltextindex erstellen", self.iface.mainWindow())
self.fulltextindex.setWhatsThis(u"Erzeugt einen Volltextindex in der Datenbank um die Suche zu beschleunigen")
self.fulltextindex.setStatusTip(u"Erzeugt einen Volltextindex in der Datenbank um die Suche zu beschleunigen")
self.fulltextindex.triggered.connect(self.createFulltextindex)
if hasattr(self.iface, "addPluginToDatabaseMenu"):
self.iface.addPluginToDatabaseMenu("&PostNAS-Suche", self.fulltextindex)
else:
self.iface.addPluginToMenu("&PostNAS-Suche", self.fulltextindex)
# Create action that will start plugin configuration
self.action = QAction(QIcon(":/plugins/PostNAS_Search/search_24x24.png"),u"Flurstücksuche", self.iface.mainWindow())
self.action.setCheckable(True)
# connect the action to the run method
self.action.triggered.connect(self.toggleWidget)
# Add toolbar button and menu item
self.iface.addToolBarIcon(self.action)
def toggleWidget(self, event):
if self.searchDockWidget == None:
self.searchDockWidget = QDockWidget(self.iface.mainWindow())
self.searchDockWidget.setWindowTitle(self.tr(u'Suche'))
self.searchDockWidget.setWidget(self.dlg)
self.searchDockWidget.closeEvent = self.toggleWidget
self.iface.addDockWidget(self.searchDockWidgetArea, self.searchDockWidget)
self.action.setChecked(True)
else:
self.searchDockWidgetArea = self.iface.mainWindow().dockWidgetArea(self.searchDockWidget)
self.iface.removeDockWidget(self.searchDockWidget)
self.searchDockWidget = None
self.action.setChecked(False)
def showConf(self):
dlg = PostNAS_ConfDialog(self)
dlg.exec_()
def createFulltextindex(self):
dlg = PostNAS_CreateFulltextindex(self)
dlg.exec_()
def unload(self):
# Remove the Toolbar Icon
self.iface.removeToolBarIcon(self.action)
#.........这里部分代码省略.........
示例11: GimpSelectionFeaturePlugin
# 需要导入模块: from qgis.PyQt.QtWidgets import QAction [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QAction import setWhatsThis [as 别名]
class GimpSelectionFeaturePlugin(QObject):
def __init__(self, iface):
super().__init__()
self.iface = iface
self.name = u"&Gimp Selection Feature"
self.dock = self.exitsPluginGimp = None
self.translate = Translate( 'gimpselectionfeature' )
def initGui(self):
def setExistsPluginGimp():
def getDirPluginGimp():
dirPlugin = None
mask = r".*gimp.[0-9]+.[0-9]+/%s" % nameDirPlugin # Linux Format
for root, dirs, files in os.walk( dirHome ):
if re.match( mask, root.replace('\\', '/'), re.IGNORECASE ):
dirPlugin = root
break
return dirPlugin
def copyNewPlugin():
shutil.copy2( gimpPlugin, gimpPluginInstall )
if sys.platform != 'win32': # Add executable
st = os.stat( gimpPluginInstall )
os.chmod( gimpPluginInstall, st.st_mode | stat.S_IEXEC )
dirHome = os.path.expanduser('~')
nameDirPlugin = "plug-ins"
dirPluginGimp = getDirPluginGimp()
if dirPluginGimp is None:
msg = "Not found diretory 'GIMP' or 'GIMP {}' in '{}'".format( nameDirPlugin, dirHome )
self.exitsPluginGimp = { 'isOk': False, 'msg': msg }
return
namePlugin = 'socket_server_selection.py'
gimpPlugin = os.path.join( os.path.dirname(__file__), namePlugin )
gimpPluginInstall = os.path.join( dirPluginGimp, namePlugin )
if not os.path.exists( gimpPluginInstall ) or not filecmp.cmp( gimpPlugin, gimpPluginInstall ):
copyNewPlugin()
self.exitsPluginGimp = { 'isOk': True }
name = "Gimp Selection Feature"
about = QCoreApplication.translate('GimpSelectionFeature', 'Adding selected area in GIMP how a feature in shapefile')
icon = QIcon( os.path.join( os.path.dirname(__file__), 'gimpselectionfeature.svg' ) )
self.action = QAction( icon, name, self.iface.mainWindow() )
self.action.setObjectName( name.replace(' ', '') )
self.action.setWhatsThis( about )
self.action.setStatusTip( about )
self.action.setCheckable( True )
self.action.triggered.connect( self.run )
self.iface.addRasterToolBarIcon( self.action )
self.iface.addPluginToRasterMenu( self.name, self.action )
setExistsPluginGimp()
if not self.exitsPluginGimp['isOk']:
return
self.dock = DockWidgetGimpSelectionFeature( self.iface )
self.iface.addDockWidget( Qt.RightDockWidgetArea , self.dock )
self.dock.visibilityChanged.connect( self.dockVisibilityChanged )
def unload(self):
self.iface.removeRasterToolBarIcon( self.action )
self.iface.removePluginRasterMenu( self.name, self.action )
if self.exitsPluginGimp['isOk']:
self.dock.close()
del self.dock
self.dock = None
del self.action
@pyqtSlot()
def run(self):
if not self.exitsPluginGimp['isOk']:
( t, m ) = ( GimpSelectionFeature.nameModulus, self.exitsPluginGimp['msg'] )
self.iface.messageBar().pushMessage( t, m, Qgis.Critical, 5 )
self.action.setChecked( False )
return
if self.dock.isVisible():
self.dock.hide()
else:
self.dock.show()
@pyqtSlot(bool)
def dockVisibilityChanged(self, visible):
self.action.setChecked( visible )
示例12: add_action
# 需要导入模块: from qgis.PyQt.QtWidgets import QAction [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QAction import setWhatsThis [as 别名]
def add_action(
self,
icon_path,
text,
callback,
enabled_flag=True,
add_to_menu=True,
add_to_toolbar=True,
status_tip=None,
whats_this=None,
parent=None):
"""Add a toolbar icon to the InaSAFE toolbar.
:param icon_path: Path to the icon for this action. Can be a resource
path (e.g. ':/plugins/foo/bar.png') or a normal file system path.
:type icon_path: str
:param text: Text that should be shown in menu items for this action.
:type text: str
:param callback: Function to be called when the action is triggered.
:type callback: function
:param enabled_flag: A flag indicating if the action should be enabled
by default. Defaults to True.
:type enabled_flag: bool
:param add_to_menu: Flag indicating whether the action should also
be added to the menu. Defaults to True.
:type add_to_menu: bool
:param add_to_toolbar: Flag indicating whether the action should also
be added to the toolbar. Defaults to True.
:type add_to_toolbar: bool
:param status_tip: Optional text to show in a popup when mouse pointer
hovers over the action.
:type status_tip: str
:param parent: Parent widget for the new action. Defaults None.
:type parent: QWidget
:param whats_this: Optional text to show in the status bar when the
mouse pointer hovers over the action.
:returns: The action that was created. Note that the action is also
added to self.actions list.
:rtype: QAction
"""
icon = QIcon(icon_path)
action = QAction(icon, text, parent)
action.triggered.connect(callback)
action.setEnabled(enabled_flag)
if status_tip is not None:
action.setStatusTip(status_tip)
if whats_this is not None:
action.setWhatsThis(whats_this)
if add_to_toolbar:
self.toolbar.addAction(action)
if add_to_menu:
self.iface.addPluginToVectorMenu(
self.menu,
action)
self.actions.append(action)
return action
示例13: __init__
# 需要导入模块: from qgis.PyQt.QtWidgets import QAction [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QAction import setWhatsThis [as 别名]
class midv_tolkn:
def __init__(self, iface):
# Save reference to the QGIS interface
self.iface = iface
# initialize plugin directory
self.plugin_dir = os.path.dirname(QFile.decodeName(__file__))
self.db = None
def initGui(self):
# Create actions
icon = QIcon(os.path.join(self.plugin_dir, "icons", "midv_tolkn.png"))
self.actionloadthelayers = QAction(QIcon(":/plugins/midv_tolkn/icons/load_layers_domains.png"), "Ladda tolkningslager t QGIS", self.iface.mainWindow())
self.actionloadthelayers.setWhatsThis("Laddar tolkningslager för gvmagasin m.m. till QGIS")
self.actionloadthelayers.triggered.connect(lambda x: self.load_the_layers())
self.actionNewDB = QAction(QIcon(":/plugins/midv_tolkn/icons/create_new.png"), "Skapa en ny tolkningsdatabas", self.iface.mainWindow())
self.actionNewDB.triggered.connect(lambda x: self.new_db())
self.actionVacuumDB = QAction(QIcon(":/plugins/midv_tolkn/icons/vacuum.png"), "Packa (vacuum) tolkn-db", self.iface.mainWindow())
self.actionVacuumDB.setWhatsThis("Perform database vacuuming")
self.actionVacuumDB.triggered.connect(lambda x: self.vacuum_db())
self.actionZipDB = QAction(QIcon(":/plugins/midv_tolkn/icons/zip.png"), "Backup av tolknings-databas", self.iface.mainWindow())
self.actionZipDB.setWhatsThis("En komprimerad zip-fil kommer att skapas i samma dir som tolknings-databasen.")
self.actionZipDB.triggered.connect(lambda x: self.zip_db())
self.actionUpgradeDB = QAction(QIcon(":/plugins/midv_tolkn/icons/create_new.png"), "Uppgradera tolknings-databas", self.iface.mainWindow())
self.actionUpgradeDB.setWhatsThis("Uppgradera en befintlig tolknings-databas till ny databas-struktur.")
self.actionUpgradeDB.triggered.connect(lambda x: self.upgrade_db())
#self.actionabout = QAction(QIcon(":/plugins/midv_tolkn/icons/about.png"), "Information", self.iface.mainWindow())
#self.actionabout.triggered.connect(lambda x: self.about)
# Add button
self.iface.addToolBarIcon(self.actionloadthelayers)
# Add plugins menu items
self.midv_menu = None # Midvatten-plugin-menyn
self.menu = None # sub-menyn "Tolkningar"
# Check if Midvatten-menyn existerar och get it
for child in self.iface.mainWindow().menuBar().children():
if isinstance(child,QMenu):
if child.title() == "Midvatten": # Put here your menu name
self.midv_menu = child
# If the Midvatten menu does not exist, create it!
self.owns_midv_menu = False #indicator that this plugin must not clean up the midvatten menu
if not self.midv_menu:
self.owns_midv_menu = True #indicator that this plugin must clean up the midvatten menu
self.midv_menu = QMenu( "Midvatten", self.iface.mainWindow().menuBar() )
menuBar = self.iface.mainWindow().menuBar()
menuBar.addMenu(self.midv_menu)
# check if there is a sub-menu Tolkningar
for childchild in self.midv_menu.children():
if isinstance(childchild,QMenu):
if childchild.title() == "&Tolkningar": # Put here your menu name
print('found sub-menu Tolkningar')
self.menu = childchild
# If the tolkning submenu does not exist, create it
if not self.menu:
print('will add Tolkningar submenu')
self.menu_separator1 = self.midv_menu.addSeparator()
self.menu = QMenu(QCoreApplication.translate("Midvatten", "&Tolkningar"))
self.midv_menu.addMenu(self.menu)
self.menu_separator2 = self.midv_menu.addSeparator()
self.menu.addAction(self.actionloadthelayers)
self.menu.addAction(self.actionNewDB)
self.menu.addAction(self.actionVacuumDB)
self.menu.addAction(self.actionZipDB)
self.menu.addAction(self.actionUpgradeDB)
#self.menu.addAction(self.actionabout)
def unload(self):
# remove tool bar button
self.iface.removeToolBarIcon(self.actionloadthelayers)
# Remove the plugin menu items and icons
try:
self.midv_menu.removeAction(self.menu.menuAction())
self.midv_menu.removeAction(self.menu_separator1)
self.midv_menu.removeAction(self.menu_separator2)
except:
pass
if self.owns_midv_menu: #indicator that this plugin must clean up the midvatten menu
menubar = self.midv_menu.parentWidget()
menubar.removeAction(self.midv_menu.menuAction())
self.midv_menu.deleteLater()
def about(self):
utils.pop_up_info(msg='This feature is not yet implemented',title='Hold on...')
def load_data_domains(self):
#utils.pop_up_info(msg='This feature is not yet implemented',title='Hold on...')
#return
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
#.........这里部分代码省略.........
示例14: qgsazimuth
# 需要导入模块: from qgis.PyQt.QtWidgets import QAction [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QAction import setWhatsThis [as 别名]
class qgsazimuth(object):
"""
Base class for the qgsAzimuth plugin
- Provides a means to draw a feature by specifying the angle and distance beetween points.
- Supports angles in either the conventional 0.0 - 360.0 clockwise from North
or the surveyor's 'Easting' system with bearings plus or minus 90 deg. from North or South
- Supports magnetic declination as degrees plus or minus for East or West respectively
- supports inputs in feet or the current CRS units
"""
# just a test to see if mods are taking
def __init__(self, iface):
self.iface = iface
self.canvas = iface.mapCanvas()
self.fPath = (
""
) # set default working directory, updated from config file & by Import/Export
self.bands = []
def initGui(self):
# create action that will start plugin configuration
self.action = QAction(
QIcon(":icons/qgsazimuth.png"),
"Azimuth and distance",
self.iface.mainWindow(),
)
self.action.setWhatsThis("Azimuth and distance")
self.action.triggered.connect(self.run)
self.bandpoint = QgsRubberBand(self.canvas, QgsWkbTypes.PointGeometry)
self.bandpoint.setIcon(QgsRubberBand.ICON_CROSS)
self.bandpoint.setColor(QColor.fromRgb(255, 50, 255))
self.bandpoint.setWidth(3)
self.bandpoint.setIconSize(20)
# add toolbar button and menu item
self.iface.addPluginToMenu("&Topography", self.action)
self.iface.addToolBarIcon(self.action)
self.dock = Dock(self.iface.mainWindow())
self.iface.addDockWidget(Qt.BottomDockWidgetArea, self.dock)
self.dock.hide()
self.pluginGui = self.dock.widget()
self.dock.closed.connect(self.cleanup)
self.pluginGui.pushButton_vertexAdd.clicked.connect(self.addRow)
self.pluginGui.pushButton_vertexInsert.clicked.connect(self.insertRow)
self.pluginGui.pushButton_segListRowDel.clicked.connect(self.delRow)
self.pluginGui.pushButton_segListLoad.clicked.connect(self.loadList)
self.pluginGui.pushButton_segListClear.clicked.connect(self.clearList)
self.pluginGui.pushButton_objectDraw.clicked.connect(self.addgeometry)
self.pluginGui.pushButton_startCapture.clicked.connect(self.startgetpoint)
self.pluginGui.pushButton_segListSave.clicked.connect(self.saveList)
self.pluginGui.pushButton_useLast.clicked.connect(self.use_last_vertex)
self.pluginGui.pickAngle1_button.clicked.connect(self.select_angle1)
self.pluginGui.pickAngle2_button.clicked.connect(self.select_angle2)
self.pluginGui.clearMarkers_button.clicked.connect(self.clear_markers)
self.pluginGui.copyDiff_button.clicked.connect(self.copy_diff_offset)
# self.pluginGui.table_segmentList.cellChanged.connect(self.render_temp_band)
self.pluginGui.table_segmentList.setCurrentCell(0, 0)
self.tool = GetCoordTool(self.canvas)
self.tool.finished.connect(self.getpoint)
self.tool.locationChanged.connect(self.pluginGui.update_startpoint)
self.tool.locationChanged.connect(self.update_marker_location)
self.angletool = LineTool(self.canvas)
self.angletool.geometryComplete.connect(self.update_angle1)
self.angletool.locationChanged.connect(self.update_marker_location)
self.angletool2 = LineTool(self.canvas)
self.angletool2.geometryComplete.connect(self.update_angle2)
self.angletool2.locationChanged.connect(self.update_marker_location)
self.pluginGui.azimuth1_edit.textChanged.connect(self.update_angle_calc)
self.pluginGui.azimuth2_edit.textChanged.connect(self.update_angle_calc)
self.pluginGui.lineEdit_magNorth.textChanged.connect(self.update_offsetlabel)
self.pluginGui.radioButton_defaultNorth.toggled.connect(self.update_offsetlabel)
def update_offsetlabel(self, *args):
mag = self.mag_dev
self.pluginGui.offsetLabel.setText(str(mag))
def copy_diff_offset(self):
diff = self.pluginGui.azimuthDiff_edit.text()
self.pluginGui.lineEdit_magNorth.setText(diff)
def clear_markers(self):
self.angletool2.reset()
self.angletool.reset()
self.pluginGui.azimuth1_edit.setText(str(0))
self.pluginGui.azimuth2_edit.setText(str(0))
def update_angle_calc(self):
a1 = self.pluginGui.azimuth1_edit.text()
#.........这里部分代码省略.........
示例15: SeilaplanPlugin
# 需要导入模块: from qgis.PyQt.QtWidgets import QAction [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QAction import setWhatsThis [as 别名]
class SeilaplanPlugin(object):
"""QGIS Plugin Implementation."""
def __init__(self, iface):
# Save reference to the QGIS interface
self.iface = iface
# Initialize plugin directory
self.plugin_dir = os.path.dirname(__file__)
# Initialize locale
locale = QSettings().value("locale/userLocale")[0:2]
localePath = os.path.join(self.plugin_dir, 'i18n',
'SeilaplanPlugin_{}.qm'.format(locale))
if os.path.exists(localePath):
self.translator = QTranslator()
self.translator.load(localePath)
if qVersion() > '4.3.3':
QCoreApplication.installTranslator(self.translator)
self.action = None
self.progressDialog = None
self.dlg = None
# try:
# import pydevd
# pydevd.settrace('localhost', port=53100,
# stdoutToServer=True, stderrToServer=True)
# except ConnectionRefusedError:
# pass
# except ImportError:
# pass
def initGui(self):
# Create action that will start plugin configuration
self.action = QAction(
QIcon(":/plugins/SeilaplanPlugin/icons/icon_app.png"),
"SEILAPLAN", self.iface.mainWindow())
self.action.setWhatsThis("SEILAPLAN")
# Connect the action to the run method
self.action.triggered.connect(self.run)
# Add toolbar button and menu item
self.iface.addToolBarIcon(self.action)
self.iface.addPluginToMenu("&SEILAPLAN", self.action)
def unload(self):
"""Removes the plugin menu item and icon from QGIS GUI."""
self.iface.removePluginMenu('&SEILAPLAN', self.action)
self.iface.removeToolBarIcon(self.action)
def run(self):
"""Run method that performs all the real work"""
# Control variables for possible rerun of algorithm
reRun = True
reRunProj = None
while reRun:
# Create seperate threa for calculations so that QGIS stays
# responsive
workerThread = ProcessingTask()
# Initialize dialog window
self.dlg = SeilaplanPluginDialog(self.iface, workerThread)
# Get available raster from table of content in QGIS
self.dlg.updateRasterList()
# Load initial values of dialog
self.dlg.loadInitialVals()
# If this is a rerun of the algorithm the previous user values are
# loaded into the GUI
if reRunProj:
self.dlg.loadProj(reRunProj)
self.dlg.show()
# Start event loop
self.dlg.exec_()
reRun = False
reRunProj = None
# The algorithm is executed in a separate thread. To see progress,
# a new gui shows a progress bar.
# If all needed data has been input in the gui and the user has
# clicked 'ok'
if workerThread.state is True:
# Initialize gui to show progress
self.progressDialog = ProgressDialog(self.iface)
self.progressDialog.setThread(workerThread)
# Add task to taskmanager of QGIS and start the calculations
QgsApplication.taskManager().addTask(workerThread)
#.........这里部分代码省略.........