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


Python QgsApplication.processEvents方法代码示例

本文整理汇总了Python中qgis.core.QgsApplication.processEvents方法的典型用法代码示例。如果您正苦于以下问题:Python QgsApplication.processEvents方法的具体用法?Python QgsApplication.processEvents怎么用?Python QgsApplication.processEvents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qgis.core.QgsApplication的用法示例。


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

示例1: progress_callback

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import processEvents [as 别名]
    def progress_callback(self, current_value, maximum_value, message=None):
        """GUI based callback implementation for showing progress.

        :param current_value: Current progress.
        :type current_value: int

        :param maximum_value: Maximum range (point at which task is complete.
        :type maximum_value: int

        :param message: Optional message dictionary to containing content
            we can display to the user. See safe.definitions.analysis_steps
            for an example of the expected format
        :type message: dict
        """
        report = m.Message()
        report.add(LOGO_ELEMENT)
        report.add(m.Heading(
            tr('Analysis status'), **INFO_STYLE))
        if message is not None:
            report.add(m.ImportantText(message['name']))
            report.add(m.Paragraph(message['description']))
        report.add(self.impact_function.performance_log_message())
        send_static_message(self, report)
        self.progress_bar.setMaximum(maximum_value)
        self.progress_bar.setValue(current_value)
        QgsApplication.processEvents()
开发者ID:inasafe,项目名称:inasafe,代码行数:28,代码来源:step_fc90_analysis.py

示例2: updateProgressBar

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import processEvents [as 别名]
 def updateProgressBar(self, progressValue):
     QgsApplication.processEvents()
     if self.progressBar and not self.lockProgressBar:
         self.lockProgressBar = True
         self.progressBar.setValue(progressValue)
         self.progressValue = progressValue
         self.lockProgressBar = False
开发者ID:IGNF,项目名称:saisie_carhab,代码行数:9,代码来源:import_layer.py

示例3: show_busy

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import processEvents [as 别名]
 def show_busy(self):
     """Lock buttons and enable the busy cursor."""
     self.progress_bar.show()
     self.parent.pbnNext.setEnabled(False)
     self.parent.pbnBack.setEnabled(False)
     self.parent.pbnCancel.setEnabled(False)
     self.parent.repaint()
     enable_busy_cursor()
     QgsApplication.processEvents()
开发者ID:inasafe,项目名称:inasafe,代码行数:11,代码来源:step_fc90_analysis.py

示例4: progress

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import processEvents [as 别名]
  def progress(self, percentage=None, statusMsg=None):
    ui = self.ui
    if percentage is not None:
      ui.progressBar.setValue(percentage)
      if percentage == 100:
        ui.progressBar.setVisible(False)
        ui.label_Status.setText("")
      else:
        ui.progressBar.setVisible(True)

    if statusMsg is not None:
      ui.label_Status.setText(statusMsg)
      ui.label_Status.repaint()
    QgsApplication.processEvents(QEventLoop.ExcludeUserInputEvents)
开发者ID:biapar,项目名称:Qgis2threejs,代码行数:16,代码来源:qgis2threejsdialog.py

示例5: progress_event

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import processEvents [as 别名]
            def progress_event(received, total):
                """Update progress.

                :param received: Data received so far.
                :type received: int

                :param total: Total expected data.
                :type total: int
                """
                # noinspection PyArgumentList
                QgsApplication.processEvents()

                self.progress_dialog.adjustSize()

                human_received = humanize_file_size(received)
                human_total = humanize_file_size(total)

                label_text = tr("%s : %s of %s" % (
                    self.prefix_text, human_received, human_total))

                self.progress_dialog.setLabelText(label_text)
                self.progress_dialog.setMaximum(total)
                self.progress_dialog.setValue(received)
开发者ID:inasafe,项目名称:inasafe,代码行数:25,代码来源:file_downloader.py

示例6: removeProgressBar

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import processEvents [as 别名]
 def removeProgressBar(self, msgBarItem):
     self.progressBar = None
     if self.progressValue != 100:  # To recognize an abortement by user of import.
         QgsApplication.processEvents()
         self.worker.stop = True
开发者ID:IGNF,项目名称:saisie_carhab,代码行数:7,代码来源:import_layer.py

示例7: download

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import processEvents [as 别名]
    def download(self):
        """Downloading the file.

        :returns: True if success, otherwise returns a tuple with format like
            this (QNetworkReply.NetworkError, error_message)

        :raises: IOError - when cannot create output_path
        """
        # Prepare output path
        self.output_file = QFile(self.output_path)
        if not self.output_file.open(QFile.WriteOnly):
            raise IOError(self.output_file.errorString())

        # Prepare downloaded buffer
        self.downloaded_file_buffer = QByteArray()

        # Request the url
        request = QNetworkRequest(self.url)
        self.reply = self.manager.get(request)
        self.reply.readyRead.connect(self.get_buffer)
        self.reply.finished.connect(self.write_data)
        self.manager.requestTimedOut.connect(self.request_timeout)

        if self.progress_dialog:
            # progress bar
            def progress_event(received, total):
                """Update progress.

                :param received: Data received so far.
                :type received: int

                :param total: Total expected data.
                :type total: int
                """
                # noinspection PyArgumentList
                QgsApplication.processEvents()

                self.progress_dialog.adjustSize()

                human_received = humanize_file_size(received)
                human_total = humanize_file_size(total)

                label_text = tr("%s : %s of %s" % (
                    self.prefix_text, human_received, human_total))

                self.progress_dialog.setLabelText(label_text)
                self.progress_dialog.setMaximum(total)
                self.progress_dialog.setValue(received)

            # cancel
            def cancel_action():
                """Cancel download."""
                self.reply.abort()
                self.reply.deleteLater()

            self.reply.downloadProgress.connect(progress_event)
            self.progress_dialog.canceled.connect(cancel_action)

        # Wait until finished
        # On Windows 32bit AND QGIS 2.2, self.reply.isFinished() always
        # returns False even after finished slot is called. So, that's why we
        # are adding self.finished_flag (see #864)
        while not self.reply.isFinished() and not self.finished_flag:
            # noinspection PyArgumentList
            QgsApplication.processEvents()

        result = self.reply.error()
        try:
            http_code = int(self.reply.attribute(
                QNetworkRequest.HttpStatusCodeAttribute))
        except TypeError:
            # If the user cancels the request, the HTTP response will be None.
            http_code = None

        self.reply.abort()
        self.reply.deleteLater()

        if result == QNetworkReply.NoError:
            return True, None

        elif result == QNetworkReply.UnknownNetworkError:
            return False, tr(
                'The network is unreachable. Please check your internet '
                'connection.')

        elif http_code == 408:
            msg = tr(
                'Sorry, the server aborted your request. '
                'Please try a smaller area.')
            LOGGER.debug(msg)
            return False, msg

        elif http_code == 509:
            msg = tr(
                'Sorry, the server is currently busy with another request. '
                'Please try again in a few minutes.')
            LOGGER.debug(msg)
            return False, msg

        elif result == QNetworkReply.ProtocolUnknownError or \
#.........这里部分代码省略.........
开发者ID:inasafe,项目名称:inasafe,代码行数:103,代码来源:file_downloader.py

示例8: translate_callback

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import processEvents [as 别名]
 def translate_callback(self, pct, msg, user_data):
     self.progress_dlg.setValue(int(100*pct))
     QgsApplication.processEvents(QEventLoop.ExcludeUserInputEvents)
     if self.progress_dlg.wasCanceled():
         return 0
     return 1
开发者ID:Oslandia,项目名称:gml_application_schema_toolbox,代码行数:8,代码来源:gmlas_panel_mixin.py

示例9: insert_line

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import processEvents [as 别名]
    def insert_line(self):
        layer = self.iface.activeLayer()
        if not isinstance(layer, QgsVectorLayer) or layer.geometryType() != QGis.Line:
            self.iface.messageBar().pushMessage(self.tr("ReconstructLine"),
                                    self.tr("Line can\'t be inserted! Select lines layer for inserting new geom!"),
                                    level=QgsMessageBar.WARNING,
                                    duration=5)
            return

        if not layer.isEditable():
            self.iface.messageBar().pushMessage(self.tr("ReconstructLine"),
                                    self.tr("Line can\'t be inserted! Layer is not editable!"),
                                    level=QgsMessageBar.WARNING,
                                    duration=5)
            return

        if not self._geom_buffer:
            self.iface.messageBar().pushMessage(self.tr("ReconstructLine"),
                        self.tr("Line can\'t be inserted! Copy points first!"),
                        level=QgsMessageBar.WARNING,
                        duration=5)
            return

        #show message
        self.iface.messageBar().clearWidgets()
        self.iface.messageBar().pushMessage(self.tr("ReconstructLine"),
                                            self.tr("Processing points. Please wait..."),
                                            level=QgsMessageBar.INFO
                                            )
        QgsApplication.setOverrideCursor(Qt.WaitCursor)
        QgsApplication.processEvents()
        QgsApplication.processEvents()
        QgsApplication.processEvents()

        try:
            # Create line

            # QGS geoms to np
            points = [(in_geom.x(), in_geom.y()) for in_geom in self._geom_buffer]
            data = np.array(points)

            # Make line
            som = SOM1d(data)
            result = som.connect()

            #np to QGS
            self._geom_buffer = [QgsPoint(out_geom[0], out_geom[1]) for out_geom in result]

            if layer.wkbType() == QGis.WKBMultiLineString:
                geom = QgsGeometry.fromMultiPolyline([self._geom_buffer])
            else:
                geom = QgsGeometry.fromPolyline(self._geom_buffer)

            # Check crs and reproject
            target_crs = layer.crs()
            if target_crs.srsid() != self._srid.srsid():
                transf = QgsCoordinateTransform(self._srid, target_crs)
                geom.transform(transf)

            # Insert feature
            feat = QgsFeature()
            feat.setFields(layer.dataProvider().fields())
            feat.setGeometry(geom)

            suppressForm = QSettings().value("/qgis/digitizing/disable_enter_attribute_values_dialog", type=bool, defaultValue=False)

            if suppressForm:
                # quite insert feature
                result = layer.addFeatures([feat])
            else:
                # show dialog
                QgsApplication.restoreOverrideCursor()
                attrDialog = QgsAttributeDialog(layer, feat, False)
                attrDialog.setIsAddDialog(True)
                result = attrDialog.exec_()

            # show message
            self.iface.messageBar().clearWidgets()
            if result:
                self.iface.messageBar().pushMessage(self.tr("ReconstructLine"),
                                                self.tr("One line was sucesfull added"),
                                                level=QgsMessageBar.INFO)
            else:
                self.iface.messageBar().pushMessage(self.tr("ReconstructLine"),
                                                self.tr("Line was not added"),
                                                level=QgsMessageBar.CRITICAL)

            self.iface.mapCanvas().refresh()
        finally:
            QgsApplication.restoreOverrideCursor()
开发者ID:nextgis,项目名称:ngq_compulink,代码行数:92,代码来源:reconstruct_line.py

示例10: addFeatures

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import processEvents [as 别名]
 def addFeatures(self, layerid, features, fields, points=None, lines=None, polygons=None, permissions={}, add_empty=False, addToMap=True):
     """ Add DIVI layer to QGIS """
     qgis_fields = [ QgsField(field['key'], self.TYPES_MAP.get(field['type'], QVariant.String)) for field in fields ]
     #print (qgis_fields)
     #print (points, lines, polygons)
     if points is not None:
         points_pr = points.dataProvider()
         if points_pr.fields():
             points_pr.deleteAttributes(list(range(len(points_pr.fields()))))
         points_pr.addAttributes(qgis_fields)
         points.updateFields()
     if lines is not None:
         lines_pr = lines.dataProvider()
         if lines_pr.fields():
             lines_pr.deleteAttributes(list(range(len(lines_pr.fields()))))
         lines_pr.addAttributes(qgis_fields)
         lines.updateFields()
     if polygons is not None:
         polygons_pr = polygons.dataProvider()
         if polygons_pr.fields():
             polygons_pr.deleteAttributes(list(range(len(polygons_pr.fields()))))
         x = polygons_pr.addAttributes(qgis_fields)
         polygons.updateFields()
     #Lists of QGIS features
     points_list = []
     lines_list = []
     polygons_list = []
     count = float(len(features))
     points_ids = []
     lines_ids = []
     polygons_ids = []
     for i, feature in enumerate(features, start=1):
         #Geometria w formacie WKB zakodowanym przez base64
         geom = QgsGeometry()
         geom.fromWkb(b64decode(feature['geometry']))
         f = QgsFeature()
         f.setGeometry(geom)
         f.setAttributes([ feature['properties'].get(field['key']) for field in fields ])
         #Add feature to list by geometry type
         if geom.type() == QgsWkbTypes.PointGeometry:
             points_list.append(f)
             points_ids.append(feature['id'])
         elif geom.type() == QgsWkbTypes.LineGeometry:
             lines_list.append(f)
             lines_ids.append(feature['id'])
         elif geom.type() == QgsWkbTypes.PolygonGeometry:
             polygons_list.append(f)
             polygons_ids.append(feature['id'])
         else:
             continue
         if self.msgBar is not None:
             #self.msgBar.setProgress(i/count)
             pass
             QgsApplication.processEvents()
             if self.msgBar.aborted:
                 #Użytkownik anulował operację
                 return []
     #Add only layers that have features
     result = []
     register = partial(self.registerLayer, layerid=layerid, permissions=permissions,
         addToMap=addToMap, fields=fields)
     if points is not None and (points_list or add_empty):
         lyr, added = register(layer=points, features=points_list)
         result.append(lyr)
         self.ids_map[points.id()] = dict(list(zip(added, points_ids)))
     if lines is not None and (lines_list or add_empty):
         lyr, added = register(layer=lines, features=lines_list)
         result.append(lyr)
         self.ids_map[lines.id()] = dict(list(zip(added, lines_ids)))
     if polygons is not None and (polygons_list or add_empty):
         lyr, added = register(layer=polygons, features=polygons_list)
         result.append(lyr)
         self.ids_map[polygons.id()] = dict(list(zip(added, polygons_ids)))
     return result
开发者ID:gis-support,项目名称:DIVI-QGIS-Plugin,代码行数:76,代码来源:divi_plugin.py


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