当前位置: 首页>>代码示例>>Python>>正文


Python iface.messageBar函数代码示例

本文整理汇总了Python中qgis.utils.iface.messageBar函数的典型用法代码示例。如果您正苦于以下问题:Python messageBar函数的具体用法?Python messageBar怎么用?Python messageBar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了messageBar函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: applyProfile

def applyProfile(profile, defaultProfile):
    if profile.menus is None:
        applyMenus(defaultProfile)
    if profile.buttons is None:
        applyButtons(defaultProfile)
    if profile.panels is None:
        applyPanels(defaultProfile)
    if profile.plugins is None:
        applyPlugins(defaultProfile)
    pluginErrors = applyPlugins(profile)
    applyMenus(profile)
    applyButtons(profile)
    applyPanels(profile)
    rearrangeToolbars(profile.name)
    if pluginErrors:
        widget = iface.messageBar().createMessage("Error", tr('Profile {} has been applied with errors'.format(profile.name)))
        showButton = QPushButton(widget)
        showButton.setText("View more")
        def showMore():
            dlg = QgsMessageOutput.createMessageOutput()
            dlg.setTitle('Profile errors')
            dlg.setMessage("<br><br>".join(pluginErrors), QgsMessageOutput.MessageHtml)
            dlg.showMessage()
        showButton.pressed.connect(showMore)
        widget.layout().addWidget(showButton)
        iface.messageBar().pushWidget(widget, QgsMessageBar.WARNING,
                                             duration = 5)
    else:
        iface.messageBar().pushMessage(tr('Profiles'),
                                   tr('Profile {} has been correctly applied'.format(profile.name)),
                                   level=QgsMessageBar.INFO,
                                   duration=5)
开发者ID:boundlessgeo,项目名称:qgis-profiles-plugin,代码行数:32,代码来源:utils.py

示例2: canvasReleaseEvent

 def canvasReleaseEvent(self, e):
     pt = self.toMapCoordinates(e.pos())
     mgrsCoord = self.toMgrs(pt)
     if mgrsCoord:
         clipboard = QApplication.clipboard()
         clipboard.setText(mgrsCoord)
         iface.messageBar().pushMessage("", "Coordinate %s copied to clipboard" % mgrsCoord, level=QgsMessageBar.INFO, duration=3)
开发者ID:tay7-git,项目名称:mgrs-tools,代码行数:7,代码来源:maptool.py

示例3: updatePublishedStyle

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
开发者ID:GeoCat,项目名称:qgis-geoserver-plugin,代码行数:31,代码来源:layerwatcher.py

示例4: loadConfiguration

 def loadConfiguration(self):
     ''' Function to load last conf get from settings
     '''
     if not self.project:
         return
     
     # from th eproject, get JSON filename to load
     currentVehicleClassesJson = self.project.value('/FleetComposition/fleetComposition', self.gui.defaultVehicleClassesFileName)
     
     # check if json is relative path or absolute
     if not os.path.isabs(currentVehicleClassesJson):
         currentVehicleClassesJson = os.path.join(self.projectPath, currentVehicleClassesJson)
     
     # load json conf
     try:
         with open(currentVehicleClassesJson) as confFile:
             # loaded in and OrderedDict to allow maintaining the order of classes
             # contained in the json file. This will be reflected in the order
             # shown in the sunburst visualization/editor
             self.vehicleClassesDict = json.load(confFile, object_pairs_hook=collections.OrderedDict)
             
             self.configurationLoaded.emit(True)
             
     except Exception as ex:
         self.vehicleClassesDict = None
         
         QgsMessageLog.logMessage(traceback.format_exc(), 'QTraffic', QgsMessageLog.CRITICAL)
         iface.messageBar().pushMessage(self.tr("Error loading Conf JSON file. Please check the log"), QgsMessageBar.CRITICAL)
         return
开发者ID:QTrafficmodel,项目名称:QTraffic,代码行数:29,代码来源:fleet_composition_tab_manager.py

示例5: exportVectorLayer

def exportVectorLayer(layer):
    '''accepts a QgsVectorLayer or a string with a filepath'''
    settings = QtCore.QSettings()
    systemEncoding = settings.value( "/UI/encoding", "System" )
    if isinstance(layer, QgsMapLayer):
        filename = unicode(layer.source())
        destFilename = unicode(layer.name())
    else:
        filename = unicode(layer)
        destFilename = unicode(os.path.splitext(os.path.basename(filename))[0])
    if (not filename.lower().endswith("shp")):
        if not isinstance(layer, QgsMapLayer):
            layer = QgsVectorLayer(filename, "layer", "ogr")
            if not layer.isValid() or layer.type() != QgsMapLayer.VectorLayer:
                raise Exception ("Error reading file {} or it is not a valid vector layer file".format(filename))
        output = utils.tempFilenameInTempFolder(destFilename + ".shp")
        provider = layer.dataProvider()
        writer = QgsVectorFileWriter(output, systemEncoding, layer.pendingFields(), provider.geometryType(), layer.crs() )
        for feat in layer.getFeatures():
            writer.addFeature(feat)
        del writer
        iface.messageBar().pushMessage("Warning", "Layer had to be exported to shapefile for importing. Data might be lost.",
                                              level = QgsMessageBar.WARNING,
                                              duration = 5)
        return output
    else:
        return filename
开发者ID:himaps,项目名称:qgis-geoserver-plugin,代码行数:27,代码来源:exporter.py

示例6: prepareAlgorithm

    def prepareAlgorithm(self, alg):
        algInstance = alg.algorithm
        for param in algInstance.parameters:
            if not param.hidden:
                if param.name in alg.params:
                    value = self.resolveValue(alg.params[param.name], param)
                else:
                    if iface is not None:
                        iface.messageBar().pushMessage(self.tr("Warning"),
                                                       self.tr("Parameter %s in algorithm %s in the model is run with default value! Edit the model to make sure that this is correct.") % (param.name, alg.name),
                                                       QgsMessageBar.WARNING, 4)
                    value = param.default
                # We allow unexistent filepaths, since that allows
                # algorithms to skip some conversion routines
                if not param.setValue(value) and not isinstance(param,
                                                                ParameterDataObject):
                    raise GeoAlgorithmExecutionException(
                        self.tr('Wrong value %s for %s %s', 'ModelerAlgorithm')
                        % (value, param.__class__.__name__, param.name))

        for out in algInstance.outputs:
            if not out.hidden:
                if out.name in alg.outputs:
                    name = self.getSafeNameForOutput(alg.name, out.name)
                    modelOut = self.getOutputFromName(name)
                    if modelOut:
                        out.value = modelOut.value
                else:
                    out.value = None

        return algInstance
开发者ID:wonder-sk,项目名称:QGIS,代码行数:31,代码来源:ModelerAlgorithm.py

示例7: useLayerExtent

 def useLayerExtent(self):
     CANVAS_KEY = "Use canvas extent"
     extentsDict = {}
     extentsDict[CANVAS_KEY] = {
         "extent": iface.mapCanvas().extent(),
         "authid": iface.mapCanvas().mapSettings().destinationCrs().authid(),
     }
     extents = [CANVAS_KEY]
     layers = dataobjects.getAllLayers()
     for layer in layers:
         authid = layer.crs().authid()
         if ProcessingConfig.getSetting(ProcessingConfig.SHOW_CRS_DEF) and authid is not None:
             layerName = u"{} [{}]".format(layer.name(), authid)
         else:
             layerName = layer.name()
         extents.append(layerName)
         extentsDict[layerName] = {"extent": layer.extent(), "authid": authid}
     (item, ok) = QInputDialog.getItem(self, self.tr("Select extent"), self.tr("Use extent from"), extents, False)
     if ok:
         self.setValueFromRect(extentsDict[item]["extent"])
         if extentsDict[item]["authid"] != iface.mapCanvas().mapSettings().destinationCrs().authid():
             iface.messageBar().pushMessage(
                 self.tr("Warning"),
                 self.tr(
                     "The projection of the chosen layer is not the same as canvas projection! The selected extent might not be what was intended."
                 ),
                 QgsMessageBar.WARNING,
                 8,
             )
开发者ID:Zakui,项目名称:QGIS,代码行数:29,代码来源:ExtentSelectionPanel.py

示例8: get_layers

    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
开发者ID:GeoCat,项目名称:qgis-geoserver-plugin,代码行数:34,代码来源:basecatalog.py

示例9: prepareAlgorithm

    def prepareAlgorithm(self, alg):
        algInstance = alg.algorithm
        for param in algInstance.parameterDefinitions():
            if not param.flags() & QgsProcessingParameterDefinition.FlagHidden:
                if param.name() in alg.params:
                    value = self.resolveValue(alg.params[param.name()], param)
                else:
                    if iface is not None:
                        iface.messageBar().pushMessage(self.tr("Warning"),
                                                       self.tr("Parameter {0} in algorithm {1} in the model is run with default value! Edit the model to make sure that this is correct.").format(param.name(), alg.displayName()),
                                                       QgsMessageBar.WARNING, 4)
                    value = param.defaultValue()
                # We allow unexistent filepaths, since that allows
                # algorithms to skip some conversion routines

                # TODO
                #if not param.checkValueIsAcceptable(value) and not isinstance(param,
                #                                                              ParameterDataObject):
                #    raise GeoAlgorithmExecutionException(
                #        self.tr('Wrong value {0} for {1} {2}', 'ModelerAlgorithm').format(
                #            value, param.__class__.__name__, param.name()
                #        )
                #    )

        for out in algInstance.outputs:
            if not out.flags() & QgsProcessingParameterDefinition.FlagHidden:
                if out.name() in alg.outputs:
                    name = self.getSafeNameForOutput(alg.modeler_name, out.name())
                    modelOut = self.getOutputFromName(name)
                    if modelOut:
                        out.value = modelOut.value
                else:
                    out.value = None

        return algInstance
开发者ID:rskelly,项目名称:QGIS,代码行数:35,代码来源:ModelerAlgorithm.py

示例10: OeQ_pop_status

def OeQ_pop_status():
    global OeQ_StatusWidget
    if bool(OeQ_StatusWidget):
        try:
            iface.messageBar().popWidget(OeQ_StatusWidget)
        except:
            pass
开发者ID:uvchik,项目名称:Open_eQuarter,代码行数:7,代码来源:oeq_global.py

示例11: prepareAlgorithm

    def prepareAlgorithm(self, alg):
        algInstance = alg.algorithm()
        for param in algInstance.parameterDefinitions():
            if not param.flags() & QgsProcessingParameterDefinition.FlagHidden:
                if param.name() in alg.params:
                    value = self.resolveValue(alg.params[param.name()], param)
                else:
                    if iface is not None:
                        iface.messageBar().pushMessage(self.tr("Warning"),
                                                       self.tr("Parameter {0} in algorithm {1} in the model is run with default value! Edit the model to make sure that this is correct.").format(param.name(), alg.displayName()),
                                                       QgsMessageBar.WARNING, 4)
                    value = param.defaultValue()

        # note to self - these are parameters, not outputs
        for out in algInstance.outputDefinitions():
            if not out.flags() & QgsProcessingParameterDefinition.FlagHidden:
                if out.name() in alg.outputs:
                    name = self.getSafeNameForOutput(alg.childId(), out.name())
                    modelOut = self.getOutputFromName(name)
                    if modelOut:
                        out.value = modelOut.value
                else:
                    out.value = None

        return algInstance
开发者ID:ndavid,项目名称:QGIS,代码行数:25,代码来源:ModelerAlgorithm.py

示例12: mergeInto

    def mergeInto(self, mergeInto, branch):
        conflicts = self.repo.merge(branch, mergeInto)
        if conflicts:
            ret = QMessageBox.warning(iface.mainWindow(), "Conflict(s) found while syncing",
                                      "There are conflicts between local and remote changes.\n"
                                      "Do you want to continue and fix them?",
                                      QMessageBox.Yes | QMessageBox.No)
            if ret == QMessageBox.No:
                self.repo.closeTransaction(conflicts[0].transactionId)
                return

            dlg = ConflictDialog(conflicts)
            dlg.exec_()
            solved, resolvedConflicts = dlg.solved, dlg.resolvedConflicts
            if not solved:
                self.repo.closeTransaction(conflicts[0].transactionId)
                return
            for conflict, resolution in zip(conflicts, list(resolvedConflicts.values())):
                if resolution == ConflictDialog.LOCAL:
                    conflict.resolveWithLocalVersion()
                elif resolution == ConflictDialog.REMOTE:
                    conflict.resolveWithRemoteVersion()
                elif resolution == ConflictDialog.DELETE:
                    conflict.resolveDeletingFeature()
                else:
                    conflict.resolveWithNewFeature(resolution)
            user, email = config.getUserInfo()
            if user is None:
                return
            self.repo.commitAndCloseMergeAndTransaction(user, email, "Resolved merge conflicts", conflicts[0].transactionId)


        iface.messageBar().pushMessage("GeoGig", "Branch has been correctly merged",
                                              level=QgsMessageBar.INFO, duration=5)
        repoWatcher.repoChanged.emit(self.repo)
开发者ID:boundlessgeo,项目名称:qgis-geogiglight-plugin,代码行数:35,代码来源:historyviewer.py

示例13: updateStyle

 def updateStyle():
     url = getTrackingInfo(layer)
     catalog = Catalog(url)
     wrapper = CatalogWrapper(catalog)
     wrapper.publishStyle(layer)
     iface.messageBar().popWidget()
     _resetCurrentMessageBarLayer()
开发者ID:GeoCat,项目名称:qgis-geoserver-plugin,代码行数:7,代码来源:layerwatcher.py

示例14: display_information_message_bar

def display_information_message_bar(
        title=None, message=None, more_details=None,
        button_text=tr('Show details ...'), duration=8):
    """
    Display an information message bar.

    :param title: The title of the message bar.
    :type title: str

    :param message: The message inside the message bar.
    :type message: str

    :param more_details: The message inside the 'Show details' button.
    :type more_details: str

    :param button_text: The text of the button if 'more_details' is not empty.
    :type button_text: str

    :param duration: The duration for the display, default is 8 seconds.
    :type duration: int
    """

    widget = iface.messageBar().createMessage(title, message)

    if more_details:
        button = QPushButton(widget)
        button.setText(button_text)
        button.pressed.connect(
            lambda: display_information_message_box(
                title=title, message=more_details))
        widget.layout().addWidget(button)

    iface.messageBar().pushWidget(widget, QgsMessageBar.INFO, duration)
开发者ID:Charlotte-Morgan,项目名称:inasafe,代码行数:33,代码来源:qgis_utilities.py

示例15: run

 def run(self):
     print "into thread"
     print self.lyr
     wkr = Import(self.lyr)
     self.msg_bar_item = QgsMessageBarItem("", "Import des entités", self.progress_bar)
     iface.messageBar().pushItem(self.msg_bar_item)
     wkr.progress.connect(self.update_progress_bar)
     wkr.run()
开发者ID:IGNF,项目名称:saisie_carhab,代码行数:8,代码来源:fse.py


注:本文中的qgis.utils.iface.messageBar函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。