當前位置: 首頁>>代碼示例>>Python>>正文


Python QgsMessageBar.CRITICAL屬性代碼示例

本文整理匯總了Python中qgis.gui.QgsMessageBar.CRITICAL屬性的典型用法代碼示例。如果您正苦於以下問題:Python QgsMessageBar.CRITICAL屬性的具體用法?Python QgsMessageBar.CRITICAL怎麽用?Python QgsMessageBar.CRITICAL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在qgis.gui.QgsMessageBar的用法示例。


在下文中一共展示了QgsMessageBar.CRITICAL屬性的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: process_ili_file

# 需要導入模塊: from qgis.gui import QgsMessageBar [as 別名]
# 或者: from qgis.gui.QgsMessageBar import CRITICAL [as 別名]
def process_ili_file(self, ilifile):
        fileModels = list()
        try:
            fileModels = self.parse_ili_file(ilifile, "utf-8")
        except UnicodeDecodeError:
            try:
                fileModels = self.parse_ili_file(ilifile, "latin1")
                self.new_message.emit(QgsMessageBar.WARNING,
                    self.tr('Even though the ili file `{}` could be read, it is not in UTF-8. Please encode your ili models in UTF-8.'.format(os.path.basename(ilifile))))
            except UnicodeDecodeError:
                self.new_message.emit(QgsMessageBar.CRITICAL,
                    self.tr('Could not parse ili file `{}` with UTF-8 nor Latin-1 encodings. Please encode your ili models in UTF-8.'.format(os.path.basename(ilifile))))
                QgsMessageLog.logMessage(self.tr('Could not parse ili file `{ilifile}`. We suggest you to encode it in UTF-8. ({exception})'.format(ilifile=ilifile, exception=str(e))), self.tr('Projectgenerator'))
                fileModels = list()

        return fileModels 
開發者ID:opengisch,項目名稱:projectgenerator,代碼行數:18,代碼來源:ilicache.py

示例2: run

# 需要導入模塊: from qgis.gui import QgsMessageBar [as 別名]
# 或者: from qgis.gui.QgsMessageBar import CRITICAL [as 別名]
def run(self):
        active_layer = self.iface.activeLayer()
        try:
            btm_left, top_right = bounds_from_extent(self.iface.mapCanvas().extent(), active_layer.crs())
        except AttributeError:
            self.clear_and_push_message("No active layer!", QgsMessageBar.CRITICAL, 3)
            print "be sure to have an active layer before starting the plugin"
            return

        self.dlg.show()
        self.fill_with_bounds(btm_left, top_right)
        result = self.dlg.exec_()

        if result:
            self.filename = self.dlg.lineEdit_5.text().replace(" ", "")
            self.dest_path = os.path.join(self.dlg.lineEdit_6.text(), self.filename + '.tif')
            self.bounds = (btm_left[0], btm_left[1], top_right[0], top_right[1])
            self.clear_and_push_message("DEM data is being downloaded, please wait for the process to complete", QgsMessageBar.WARNING, 10)

            import elevation
            elevation.datasource.clip(bounds=self.bounds, output=self.dest_path)

            self.clear_and_push_message("Data correctly downloaded", QgsMessageBar.INFO, 5)
            if self.dlg.preview_checkbox.isChecked():
            	self.iface.addRasterLayer(self.dest_path, '%s srtm dem' % self.filename) 
開發者ID:bopen,項目名稱:qgis-elevation-plugin,代碼行數:27,代碼來源:qgis_elevation_plugin.py

示例3: createRepo

# 需要導入模塊: from qgis.gui import QgsMessageBar [as 別名]
# 或者: from qgis.gui.QgsMessageBar import CRITICAL [as 別名]
def createRepo(self):
        name, ok = QInputDialog.getText(self, 'Create repository',
                                              'Enter the repository name:')
        if ok:
            group = self.comboEndpoint.currentText()
            url = repository.repoEndpoints[group]
            try:
                repo = execute(lambda: createRepoAtUrl(url, group, name))
            except GeoGigException as e:
                config.iface.messageBar().pushMessage("Error", str(e),
                               level=QgsMessageBar.CRITICAL,
                               duration=5)
                return
            item = RepoItem(self, self.repoTree, repo)
            addRepo(repo)
            self.repoTree.addTopLevelItem(item)
            config.iface.messageBar().pushMessage("Create repository", "Repository correctly created",
                                           level=QgsMessageBar.INFO,
                                           duration=5) 
開發者ID:boundlessgeo,項目名稱:qgis-geogiglight-plugin,代碼行數:21,代碼來源:navigatordialog.py

示例4: _addGeoGigServer

# 需要導入模塊: from qgis.gui import QgsMessageBar [as 別名]
# 或者: from qgis.gui.QgsMessageBar import CRITICAL [as 別名]
def _addGeoGigServer(self, title, url):
        try:
            repos = addRepoEndpoint(url, title)
            if not repos:
                msg = "No repositories found at the specified server"
                QMessageBox.warning(self, 'Add repositories',
                                "No repositories found at the specified server",
                                QMessageBox.Ok)


        except Exception as e:
            msg = "No geogig server found at the specified url. %s"
            QgsMessageLog.logMessage(msg % e, level=QgsMessageLog.CRITICAL)
            QMessageBox.warning(self, 'Add repositories',
                                msg % "See the logs for details.",
                                QMessageBox.Ok)

        self.comboEndpoint.addItem(title)
        self.comboEndpoint.setCurrentIndex(self.comboEndpoint.count() - 1) 
開發者ID:boundlessgeo,項目名稱:qgis-geogiglight-plugin,代碼行數:21,代碼來源:navigatordialog.py

示例5: show_message

# 需要導入模塊: from qgis.gui import QgsMessageBar [as 別名]
# 或者: from qgis.gui.QgsMessageBar import CRITICAL [as 別名]
def show_message(self, level, message):
        if level == QgsMessageBar.WARNING:
            self.bar.pushMessage(message, QgsMessageBar.INFO, 10)
        elif level == QgsMessageBar.CRITICAL:
            self.bar.pushMessage(message, QgsMessageBar.WARNING, 10) 
開發者ID:opengisch,項目名稱:projectgenerator,代碼行數:7,代碼來源:generate_project.py

示例6: workerFinished

# 需要導入模塊: from qgis.gui import QgsMessageBar [as 別名]
# 或者: from qgis.gui.QgsMessageBar import CRITICAL [as 別名]
def workerFinished(self, ret):
        #Clean up the worker and thread
        self.worker.deleteLater()
        self.thread.quit()
        self.thread.wait()
        self.thread.deleteLater()

        #Remove widget from messagebar
        self.iface.messageBar().popWidget(self.messageBar)
        if ret is not None:
            #Add the project to the map
            iface.addRasterLayer(ret, self.processName)
        else:
            #Notify the user that an error has occurred
            self.iface.messageBar().pushMessage('Something went wrong! See the message log for more information.', level=QgsMessageBar.CRITICAL, duration = 5) 
開發者ID:miltonisaya,項目名稱:landSurfaceTemperature,代碼行數:17,代碼來源:lst_tool.py

示例7: workerError

# 需要導入模塊: from qgis.gui import QgsMessageBar [as 別名]
# 或者: from qgis.gui.QgsMessageBar import CRITICAL [as 別名]
def workerError(self, e, exception_string):
        QgsMessageLog.logMessage('Worker thread raised an exception: \n'.format(exception_string), level = QgsMessageLog.CRITICAL) 
開發者ID:miltonisaya,項目名稱:landSurfaceTemperature,代碼行數:4,代碼來源:lst_tool.py

示例8: ExecutarCmdo

# 需要導入模塊: from qgis.gui import QgsMessageBar [as 別名]
# 或者: from qgis.gui.QgsMessageBar import CRITICAL [as 別名]
def ExecutarCmdo(database, host, local):
    comando = 'pg_dump -Fp -C -h ' +host+ ' -U '+Usuario+' ' +database+ ' > ' +local+ '/'+database+'.sql'
    progress.setInfo('<b>Iniciando processo de backup...</b><br/>')
    result = os.system(comando)
    if result==0:
        progress.setInfo('<b>Operacao concluida com sucesso!</b><br/><br/>')
        progress.setInfo('<b>Leandro Fran&ccedil;a - Eng Cart</b><br/>')
        time.sleep(4)
        iface.messageBar().pushMessage(u'Situacao', "Operacao Concluida com Sucesso!", level=QgsMessageBar.INFO, duration=5) 
    else:
        progress.setInfo('<b>Problema(s) durante a execucao do backup.</b><br/>')
        progress.setInfo('<b>Verifique se os parametros foram definidos corretamente.</b><br/>')
        time.sleep(8)
        iface.messageBar().pushMessage(u'Erro', "Problema(s) durante a execucao do backup.", level=QgsMessageBar.CRITICAL, duration=5) 
開發者ID:LEOXINGU,項目名稱:scripts,代碼行數:16,代碼來源:BACKUP.py

示例9: reload_repositories

# 需要導入模塊: from qgis.gui import QgsMessageBar [as 別名]
# 或者: from qgis.gui.QgsMessageBar import CRITICAL [as 別名]
def reload_repositories(self):
        """Slot for when user clicks reload repositories button."""
        # Show progress dialog
        self.show_progress_dialog('Reloading all repositories')

        for repo_name in self.repository_manager.directories:
            directory = self.repository_manager.directories[repo_name]
            url = directory['url']
            auth_cfg = directory['auth_cfg']
            try:
                status, description = self.repository_manager.reload_directory(
                    repo_name, url, auth_cfg)
                if status:
                    self.message_bar.pushMessage(
                        self.tr(
                            'Repository %s is successfully reloaded') %
                        repo_name, QgsMessageBar.INFO, 5)
                else:
                    self.message_bar.pushMessage(
                        self.tr(
                            'Unable to reload %s: %s') % (
                            repo_name, description),
                        QgsMessageBar.CRITICAL, 5)
            except Exception, e:
                self.message_bar.pushMessage(
                    self.tr('%s') % e,
                    QgsMessageBar.CRITICAL, 5)

        self.progress_dialog.hide()
        # Reload data and widget
        self.reload_data_and_widget() 
開發者ID:akbargumbira,項目名稱:qgis_resources_sharing,代碼行數:33,代碼來源:resource_sharing_dialog.py

示例10: importClicked

# 需要導入模塊: from qgis.gui import QgsMessageBar [as 別名]
# 或者: from qgis.gui.QgsMessageBar import CRITICAL [as 別名]
def importClicked(self):

        ret = QMessageBox.warning(config.iface.mainWindow(), 'Import warning',
                "Importing a layer will modify the original layer and might cause data loss.\n"
                "Make sure you have a backup copy of your layer before importing.\n"
                "Do you want to import the selected layer?",
                QMessageBox.Yes | QMessageBox.No)
        if ret == QMessageBox.No:
            return


        if self.repo is None:
            self.repo = repository.repos[self.repoCombo.currentIndex()]
        if self.layer is None:
            text = self.layerCombo.currentText()
            self.layer = layerFromName(text)

        user, email = config.getUserInfo()
        if user is None:
            self.close()
            return
        message = self.messageBox.toPlainText() or datetime.now().strftime("%Y-%m-%d %H_%M_%S")
        branch = self.branchCombo.currentText()
        try:
            self.repo.importgeopkg(self.layer, branch, message, user, email, False)
            filename, layername = namesFromLayer(self.layer)
            self.repo.checkoutlayer(filename, layername, ref = branch)
            self.layer.reload()
            self.layer.triggerRepaint()
        except GeoGigException as e:
            iface.messageBar().pushMessage("Error", str(e),
                                           level=QgsMessageBar.CRITICAL,
                                           duration=5)
            self.close()
            return

        addTrackedLayer(self.layer, self.repo.url)

        self.ok = True
        iface.messageBar().pushMessage("Layer was correctly added to repository",
                                       level=QgsMessageBar.INFO,
                                       duration=5)
        self.close() 
開發者ID:boundlessgeo,項目名稱:qgis-geogiglight-plugin,代碼行數:45,代碼來源:importdialog.py

示例11: add_repository

# 需要導入模塊: from qgis.gui import QgsMessageBar [as 別名]
# 或者: from qgis.gui.QgsMessageBar import CRITICAL [as 別名]
def add_repository(self):
        """Open add repository dialog."""
        dlg = ManageRepositoryDialog(self)
        if not dlg.exec_():
            return

        for repo in self.repository_manager.directories.values():
            if dlg.line_edit_url.text().strip() == repo['url']:
                self.message_bar.pushMessage(
                    self.tr(
                        'Unable to add another repository with the same URL!'),
                    QgsMessageBar.CRITICAL, 5)
                return

        repo_name = dlg.line_edit_name.text()
        repo_url = dlg.line_edit_url.text().strip()
        repo_auth_cfg = dlg.line_edit_auth_id.text().strip()
        if repo_name in self.repository_manager.directories:
            repo_name += '(2)'

        # Show progress dialog
        self.show_progress_dialog("Fetching repository's metadata")

        # Add repository
        try:
            status, description = self.repository_manager.add_directory(
                repo_name, repo_url, repo_auth_cfg)
            if status:
                self.message_bar.pushMessage(
                    self.tr(
                        'Repository is successfully added'),
                    QgsMessageBar.SUCCESS, 5)
            else:
                self.message_bar.pushMessage(
                    self.tr(
                        'Unable to add repository: %s') % description,
                    QgsMessageBar.CRITICAL, 5)
        except Exception, e:
            self.message_bar.pushMessage(
                self.tr('%s') % e,
                QgsMessageBar.CRITICAL, 5)
        finally:
            self.progress_dialog.hide()

        # Reload data and widget
        self.reload_data_and_widget()

        # Deactivate edit and delete button
        self.button_edit.setEnabled(False)
        self.button_delete.setEnabled(False) 
開發者ID:akbargumbira,項目名稱:qgis_resources_sharing,代碼行數:52,代碼來源:resource_sharing_dialog.py


注:本文中的qgis.gui.QgsMessageBar.CRITICAL屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。