Python qgis.utils.iface.messageBar() Examples
The following are 20
code examples of qgis.utils.iface.messageBar().
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.utils.iface
, or try the search function
.
Example #1
Source File: progressBar.py From dzetsaka with GNU General Public License v3.0 | 6 votes |
def __init__(self, inMsg=' Loading...', inMaxStep=1): """ """ # Save reference to the QGIS interface # initialize progressBar # QApplication.processEvents() # Help to keep UI alive self.iface = iface widget = iface.messageBar().createMessage('Please wait ', inMsg) prgBar = QProgressBar() self.prgBar = prgBar widget.layout().addWidget(self.prgBar) iface.messageBar().pushWidget(widget) QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) # if Max 0 and value 0, no progressBar, only cursor loading # default is set to 0 prgBar.setValue(1) # set Maximum for progressBar prgBar.setMaximum(inMaxStep)
Example #2
Source File: QgsUtils.py From QGISFMV with GNU General Public License v3.0 | 6 votes |
def showUserAndLogMessage(before, text="", level=QGis.Info, duration=3, onlyLog=False): ''' Show user & log info/warning/error messages ''' if not onlyLog: iface.messageBar().popWidget() iface.messageBar().pushMessage( before, text, level=level, duration=duration) if level == QGis.Info: log.info(text) elif level == QGis.Warning: log.warning(text) elif level == QGis.Critical: log.error(text) return # @staticmethod # def removeMosaicFolder(video_file): # ''' Remove mosaic folder ''' # folder = getVideoFolder(video_file) # out = os.path.join(folder, "mosaic") # try: # shutil.rmtree(out, ignore_errors=True) # except Exception: # None
Example #3
Source File: gsexploreritems.py From qgis-geoserver-plugin with GNU General Public License v2.0 | 6 votes |
def populate(self): stores = self.element.catalog.get_stores(workspaces=self.element) nonAscii = False for store in stores: storeItem = GsStoreItem(store) try: storeItem.populate() except UnicodeDecodeError: nonAscii = True continue self.addChild(storeItem) if nonAscii: iface.messageBar().pushMessage("Warning", "Some datasores contain non-ascii characters and could not be loaded", level = Qgis.Warning, duration = 10)
Example #4
Source File: gsexploreritems.py From qgis-geoserver-plugin with GNU General Public License v2.0 | 5 votes |
def _showSldParsingError(self): iface.messageBar().pushMessage("Warning", "Style is not stored as XML and cannot be edited", level = Qgis.Warning, duration = 10)
Example #5
Source File: mainPlugin.py From PyRAT with Mozilla Public License 2.0 | 5 votes |
def finished(self, result): """ This function is threadsafe for GUI-Actions and called after run terminates. """ if self.guionly: self.pyratTool.guirun(iface.mainWindow()) if result and not self.failed: iface.messageBar().pushMessage(self.pyratTool.name + " finished.", level=Qgis.Success) for layer in [newlayer for newlayer in pyrat.data.getLayerIDs() if newlayer not in self.existinglayers]: # Show the generated Layer(s) in QGIS anno = pyrat.data.getAnnotation(layer=layer) if 'info' not in anno: anno['info'] = "Pyrat-Layer " + layer pyrat.data.setAnnotation({'info': anno['info'] + "-" + self.pyratTool.name}, layer=layer) ViewerToQGISInterface.display[layer] = {'scaling': 'min->max', 'bwlayer': layer, 'colour': False} PyRATBridge.pyratToLayer(self.layer) PyRATBridge.layerTreeWidget.redraw() else: iface.messageBar().pushMessage(self.pyratTool.name + " failed. Look in the (system)" + " console for more information.", level=Qgis.Critical) del self.plugin
Example #6
Source File: utils.py From Load-QSS with GNU General Public License v3.0 | 5 votes |
def activateStyle(Name, iface, preview=False, close=None): name, path = getStyle(Name) if name == "" or name is None: app.setStyleSheet("") return watch.removePaths(watch.files()) iface.messageBar().clearWidgets() if path == "" or path is None: app.setStyleSheet("") return if not os.path.exists(path): iface.messageBar().pushMessage("Error: "+path+" : ", "The path to the * .qss not exist.Load default style ", level=QgsMessageBar.CRITICAL, duration=2) app.setStyleSheet("") return if close is not None: return else: reload_style(path) if preview is False: setActivated(name) iface.messageBar().pushMessage("Style "+name+" : ", "Style loaded correctly.", level=QgsMessageBar.INFO, duration=2) return else: setPreview(name) iface.messageBar().pushMessage("Style "+name+" : ", "Style Preview loaded correctly.", level=QgsMessageBar.INFO, duration=2) return
Example #7
Source File: datasourceConversion.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def run(self, conversionMap): """ Executes conversion itself based on a conversion map. :param conversionMap: (dict) the conversion map. (SPECIFY FORMAT!) """ # task = DbConverter(iface, conversionMap, description=self.tr('DSGTools Dataset Conversion')) # summaryDlg = TextBrowserDialog(parent=iface.mainWindow()) # summaryDlg.savePushButton.setEnabled(False) # task.progressChanged.connect(summaryDlg.progressBar.setValue) # task.taskCompleted.connect(lambda : summaryDlg.setHtml(task.output['log'])) # task.taskCompleted.connect(lambda : summaryDlg.cancelPushButton.setEnabled(False)) # task.taskCompleted.connect(lambda : summaryDlg.savePushButton.setEnabled(True)) # task.conversionUpdated.connect(summaryDlg.addToHtml) # summaryDlg.cancelPushButton.clicked.connect(partial(self.cancelConversion, task, summaryDlg)) # # to clear log message before repopulating with conversion summary # task.conversionFinished.connect(summaryDlg.clearHtml) # QgsApplication.taskManager().addTask(task) # summaryDlg.show() # conversion off the thread conv = DbConverter(iface, conversionMap, description=self.tr('DSGTools Dataset Conversion')) summaryDlg = TextBrowserDialog(parent=iface.mainWindow()) summaryDlg.cancelPushButton.hide() summaryDlg.progressBar.hide() try: QtWidgets.QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) if not conv.run(): # advise conversion has failed msg = self.tr("Dataset conversion has finished with some errors. Check conversion log for details.") iface.messageBar().pushMessage(self.tr('Warning!'), msg, level=Qgis.Warning, duration=5) else: self.resetInterface() QtWidgets.QApplication.restoreOverrideCursor() summaryDlg.setHtml(conv.output['log']) except Exception as e: QtWidgets.QApplication.restoreOverrideCursor() msg = self.tr("Dataset conversion has failed: '{0}'").format(', '.join(map(str, e.args))) iface.messageBar().pushMessage(self.tr('Warning!'), msg, level=Qgis.Warning, duration=5) QgsMessageLog.logMessage(':'.join(e.args), "DSGTools Plugin", Qgis.Critical) summaryDlg.exec_()
Example #8
Source File: export_raster_collar.py From albion with GNU General Public License v3.0 | 5 votes |
def accept(self): self.__project.create_raster_from_collar(self.useDepth.isChecked(), self.outDir.filePath() ) iface.messageBar().pushMessage("Export raster completed", """<a href="file:///{dir}">{dir}</a>""".format(dir=self.outDir.filePath()), level=Qgis.Info, duration=5) self.close()
Example #9
Source File: export_raster_formation.py From albion with GNU General Public License v3.0 | 5 votes |
def accept(self): self.__project.create_raster_from_formation(self.formation.currentData(), self.level.currentText(), self.outDir.filePath() ) iface.messageBar().pushMessage("Export raster completed", """<a href="file:///{dir}">{dir}</a>""".format(dir=self.outDir.filePath()), level=Qgis.Info, duration=5) self.close()
Example #10
Source File: explorer.py From qgis-geoserver-plugin with GNU General Public License v2.0 | 5 votes |
def setProgressMaximum(self, value, msg = ""): self.progressMaximum = value self.isProgressVisible = True self.progressMessageBar = iface.messageBar().createMessage(msg) self.progress = QProgressBar() self.progress.setMaximum(self.progressMaximum) self.progress.setAlignment(Qt.AlignLeft|Qt.AlignVCenter) self.progressMessageBar.layout().addWidget(self.progress) iface.messageBar().pushWidget(self.progressMessageBar, Qgis.Info)
Example #11
Source File: explorer.py From qgis-geoserver-plugin with GNU General Public License v2.0 | 5 votes |
def resetActivity(self): if self.progress is not None: iface.messageBar().clearWidgets() self.isProgressVisible = False self.progress = None self.progressMaximum = 0
Example #12
Source File: hqgis.py From Hqgis with GNU General Public License v3.0 | 5 votes |
def messageShow(self, progress, count, max): if not progress: progressMessageBar = iface.messageBar().createMessage( "Looping through " + str(max) + " records ...") progress = QProgressBar() progress.setMaximum(max) progress.setAlignment(Qt.AlignLeft | Qt.AlignVCenter) progressMessageBar.layout().addWidget(progress) iface.messageBar().pushWidget(progressMessageBar, level=1) iface.mainWindow().repaint() # return progress if progress: progress.setValue(count) return(progress)
Example #13
Source File: __init__.py From qgis-geoserver-plugin with GNU General Public License v2.0 | 5 votes |
def setError(msg, trace=None): iface.messageBar().pushMessage("Geoserver", msg, level=Qgis.Warning, duration=10) if trace is not None: QgsMessageLog.logMessage("{}:{}".format(msg, trace), level=Qgis.Critical)
Example #14
Source File: __init__.py From qgis-geoserver-plugin with GNU General Public License v2.0 | 5 votes |
def setWarning(msg): iface.messageBar().pushMessage("Warning", msg, level = Qgis.Warning, duration = 10)
Example #15
Source File: __init__.py From qgis-geoserver-plugin with GNU General Public License v2.0 | 5 votes |
def setInfo(msg): iface.messageBar().pushMessage("Info", msg, level = Qgis.Info, duration = 10)
Example #16
Source File: basecatalog.py From qgis-geoserver-plugin with GNU General Public License v2.0 | 5 votes |
def get_layers(self, resource=None): """Prefix the layer name with ws name""" lyrs = super().get_layers(resource) # Start patch: layers = {} result = [] for l in lyrs: try: layers[l.name].append(l) except KeyError: layers[l.name] = [l] # Prefix all names noAscii = False for name, ls in list(layers.items()): try: if len(ls) == 1: l = ls[0] l.name = self.get_namespaced_name(l.name) result.append(l) else: i = 0 res = self._get_res(ls[0].name) for l in ls: l.name = "%s:%s" % (res[i].workspace.name, l.name) i += 1 result.append(l) except UnicodeDecodeError: noAscii = True if noAscii: iface.messageBar().pushMessage("Warning", "Some layers contain non-ascii characters and could not be loaded", level = QgsMessageBar.WARNING, duration = 10) return result
Example #17
Source File: layerwatcher.py From qgis-geoserver-plugin with GNU General Public License v2.0 | 5 votes |
def updatePublishedStyle(layer): global _currentMessageBarLayer track = pluginSetting("TrackLayers") if track and isTrackedLayer(layer): if iface.messageBar().currentItem() is None: _resetCurrentMessageBarLayer() if _currentMessageBarLayer != layer: _currentMessageBarLayer = layer widget = iface.messageBar().createMessage("", "This layer was uploaded to a geoserver catalog. Do you want to update the published style?") updateButton = QtWidgets.QPushButton(widget) updateButton.setText("Update") def updateStyle(): url = getTrackingInfo(layer) catalog = Catalog(url) wrapper = CatalogWrapper(catalog) wrapper.publishStyle(layer) iface.messageBar().popWidget() _resetCurrentMessageBarLayer() updateButton.pressed.connect(updateStyle) widget.layout().addWidget(updateButton) stopTrackingButton = QtWidgets.QPushButton(widget) stopTrackingButton.setText("Stop tracking this layer") def stopTracking(): removeTrackedLayer(layer) iface.messageBar().popWidget() _resetCurrentMessageBarLayer() stopTrackingButton.pressed.connect(stopTracking) widget.layout().addWidget(stopTrackingButton) iface.messageBar().pushWidget(widget, Qgis.Info) iface.messageBar().currentItem().geoserverLayer = layer #iface.messageBar().widgetRemoved.connect(_resetCurrentMessageBarLayer)
Example #18
Source File: progressBar.py From dzetsaka with GNU General Public License v3.0 | 5 votes |
def reset(self): """!@brief Simply remove progressBar and reset cursor """ # Remove progressBar and back to default cursor self.iface.messageBar().clearWidgets() self.iface.mapCanvas().refresh() QApplication.restoreOverrideCursor()
Example #19
Source File: mainPlugin.py From PyRAT with Mozilla Public License 2.0 | 4 votes |
def initGui(self): """Initalise the Plugin-UI""" if not pyratImport: iface.messageBar().pushMessage("PyRAT not found!", level=Qgis.Critical) return if 'PyRAT' not in [action.text() for action in iface.mainWindow().menuBar().actions()]: self.pyratMenu = iface.mainWindow().menuBar().addMenu('PyRAT') else: self.pyratMenu = [action.menu() for action in iface.mainWindow().menuBar().actions() if action.text() == 'PyRAT'][0] action = QAction("Layer2PyRAT", iface.mainWindow()) action.triggered.connect(PyRATBridge.layerToPyrat) self.pyratMenu.addAction(action) action = QAction("PyRAT2Layer", iface.mainWindow()) action.triggered.connect(PyRATBridge.pyratToLayer) self.pyratMenu.addAction(action) action = QAction("Cleanup PyRAT", iface.mainWindow()) action.triggered.connect(PyRATBridge.clearPyRAT) self.pyratMenu.addAction(action) action = QAction("Show PyRAT GUI", iface.mainWindow()) action.triggered.connect(self.showPyrat) self.pyratMenu.addAction(action) self.pyratMenu.addSeparator() # Init PyRAT-Tools, adapted from pyrat.viewer for qgis from inspect import getmembers, isclass modules = [pyrat.load, pyrat.save, pyrat.transform, pyrat.filter, pyrat.polar, pyrat.insar, pyrat.plugins, pyrat.viewer] for current_module in modules: modules = getmembers(current_module, isclass) for mod in modules: if issubclass(mod[1], pyrat.Worker): plugin = mod[1] if(hasattr(plugin, 'gui') and plugin.gui['entry'] != "Python console"): self.addMenuEntry(plugin) self.pyratLayerTree = QDockWidget("PyRAT Layers", iface.mainWindow()) PyRATBridge.layerTreeWidget = LayerTreeWidget( parent=self.pyratLayerTree, viewer=ViewerToQGISInterface) self.pyratLayerTree.setObjectName("PyRAT Layers") self.pyratLayerTree.setWidget(PyRATBridge.layerTreeWidget) iface.addDockWidget(Qt.LeftDockWidgetArea, self.pyratLayerTree)
Example #20
Source File: hqgis.py From Hqgis with GNU General Public License v3.0 | 4 votes |
def getPlacesSingle(self): self.getCredentials() #radius = self.dlg.RadiusBox.value() categories = self.dlg.listWidget.selectedItems() categoriesList = [] for category in categories: categoriesList.append(category.text()) categories = ",".join(categoriesList) coordinates = self.dlg.placeLabel.text() url = 'https://browse.search.hereapi.com/v1/browse?at=' + coordinates + \ "&categories=" + categories + "&limit=100&apiKey=" + self.appId r = requests.get(url) print(url) if r.status_code == 200: if len(json.loads(r.text)["items"]) > 99: iface.messageBar().pushMessage( "Warning", "The maximum number of POIs for original address at " + coordinates + " of 100 POIs reached.", level=1, duration=5) if len(json.loads(r.text)["items"]) > 0: try: # as the response may hold more than one result we only use # the best one: responsePlaces = json.loads(r.text)["items"] layer = self.createPlaceLayer() features = [] for place in responsePlaces: lat = place["position"]["lat"] lng = place["position"]["lng"] # iterate over categories: categoriesResp = [] for cat in place["categories"]: categoriesResp.append(cat["id"]) fet = QgsFeature() fet.setGeometry( QgsGeometry.fromPointXY( QgsPointXY( lng, lat))) fet.setAttributes([ place["id"], place["title"], place["address"]["label"], place["distance"], ";".join(categoriesResp) ]) features.append(fet) pr = layer.dataProvider() pr.addFeatures(features) QgsProject.instance().addMapLayer(layer) except Exception as e: print(e)