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


Python QtWidgets.QMessageBox类代码示例

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


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

示例1: execute

    def execute(self):
        settings = QSettings()
        lastDir = settings.value('Processing/lastModelsDir', '')
        filename = QFileDialog.getOpenFileName(self.toolbox,
                                               self.tr('Open model', 'AddModelFromFileAction'), lastDir,
                                               self.tr('Processing model files (*.model *.MODEL)', 'AddModelFromFileAction'))
        if filename:
            try:
                settings.setValue('Processing/lastModelsDir',
                                  QFileInfo(filename).absoluteDir().absolutePath())

                ModelerAlgorithm.fromFile(filename)
            except WrongModelException:
                QMessageBox.warning(
                    self.toolbox,
                    self.tr('Error reading model', 'AddModelFromFileAction'),
                    self.tr('The selected file does not contain a valid model', 'AddModelFromFileAction'))
                return
            except:
                QMessageBox.warning(self.toolbox,
                                    self.tr('Error reading model', 'AddModelFromFileAction'),
                                    self.tr('Cannot read file', 'AddModelFromFileAction'))
                return
            destFilename = os.path.join(ModelerUtils.modelsFolder(), os.path.basename(filename))
            shutil.copyfile(filename, destFilename)
            self.toolbox.updateProvider('model')
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:26,代码来源:AddModelFromFileAction.py

示例2: batchFinished

    def batchFinished(self):
        self.base.stop()

        if len(self.errors) > 0:
            msg = u"Processing of the following files ended with error: <br><br>" + "<br><br>".join(self.errors)
            QErrorMessage(self).showMessage(msg)

        inDir = self.getInputFileName()
        outDir = self.getOutputFileName()
        if outDir is None or inDir == outDir:
            self.outFiles = self.inFiles

        # load layers managing the render flag to avoid waste of time
        canvas = self.iface.mapCanvas()
        previousRenderFlag = canvas.renderFlag()
        canvas.setRenderFlag(False)
        notCreatedList = []
        for item in self.outFiles:
            fileInfo = QFileInfo(item)
            if fileInfo.exists():
                if self.base.loadCheckBox.isChecked():
                    self.addLayerIntoCanvas(fileInfo)
            else:
                notCreatedList.append(item)
        canvas.setRenderFlag(previousRenderFlag)

        if len(notCreatedList) == 0:
            QMessageBox.information(self, self.tr("Finished"), self.tr("Operation completed."))
        else:
            QMessageBox.warning(self, self.tr("Warning"), self.tr("The following files were not created: \n{0}").format(', '.join(notCreatedList)))
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:30,代码来源:widgetBatchBase.py

示例3: setParamValues

    def setParamValues(self):
        if self.mUpdateExistingGroupBox.isChecked():
            fieldName = self.mExistingFieldComboBox.currentText()
        else:
            fieldName = self.mOutputFieldNameLineEdit.text()

        layer = dataobjects.getObjectFromName(self.cmbInputLayer.currentText())

        self.alg.setParameterValue('INPUT_LAYER', layer)
        self.alg.setParameterValue('FIELD_NAME', fieldName)
        self.alg.setParameterValue('FIELD_TYPE',
                                   self.mOutputFieldTypeComboBox.currentIndex())
        self.alg.setParameterValue('FIELD_LENGTH',
                                   self.mOutputFieldWidthSpinBox.value())
        self.alg.setParameterValue('FIELD_PRECISION',
                                   self.mOutputFieldPrecisionSpinBox.value())
        self.alg.setParameterValue('NEW_FIELD',
                                   self.mNewFieldGroupBox.isChecked())
        self.alg.setParameterValue('FORMULA', self.builder.expressionText())
        self.alg.setOutputValue('OUTPUT_LAYER', self.leOutputFile.text().strip() or None)

        msg = self.alg.checkParameterValuesBeforeExecuting()
        if msg:
            QMessageBox.warning(
                self, self.tr('Unable to execute algorithm'), msg)
            return False
        return True
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:27,代码来源:FieldsCalculatorDialog.py

示例4: activateAlgorithm

 def activateAlgorithm(self):
     if self.model.activateAlgorithm(self.element.name):
         self.model.updateModelerView()
     else:
         QMessageBox.warning(None, 'Could not activate Algorithm',
                             'The selected algorithm depends on other currently non-active algorithms.\n'
                             'Activate them them before trying to activate it.')
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:7,代码来源:ModelerGraphicItem.py

示例5: createGeomColumn

    def createGeomColumn(self):
        """ first check whether everything's fine """
        if self.editName.text() == "":
            QMessageBox.critical(self, self.tr("DB Manager"), self.tr("field name must not be empty"))
            return

        name = self.editName.text()
        geom_type = self.GEOM_TYPES[self.cboType.currentIndex()]
        dim = self.spinDim.value()
        try:
            srid = int(self.editSrid.text())
        except ValueError:
            srid = -1
        createSpatialIndex = False

        # now create the geometry column
        QApplication.setOverrideCursor(Qt.WaitCursor)
        try:
            self.table.addGeometryColumn(name, geom_type, srid, dim, createSpatialIndex)
        except DbError as e:
            DlgDbError.showError(e, self)
            return
        finally:
            QApplication.restoreOverrideCursor()

        self.accept()
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:26,代码来源:dlg_add_geometry_column.py

示例6: add_columns

    def add_columns(self):
        if self.ui.columns.currentIndex() <= 0:
            return
        ag = self.ui.columns.currentText()
        if self.evt.focus == "where":  # in where section
            if ag in self.col_where:  # column already called in where section
                response = QMessageBox.question(self, "Column already used in WHERE clause", "Do you want to add column %s again?" % ag, QMessageBox.Yes | QMessageBox.No)
                if response == QMessageBox.No:
                    self.ui.columns.setCurrentIndex(0)
                    return
            self.ui.where.insertPlainText(ag)
            self.col_where.append(ag)
        elif self.evt.focus == "col":
            if ag in self.col_col:  # column already called in col section
                response = QMessageBox.question(self, "Column already used in COLUMNS section", "Do you want to add column %s again?" % ag, QMessageBox.Yes | QMessageBox.No)
                if response == QMessageBox.No:
                    self.ui.columns.setCurrentIndex(0)
                    return
            if len(self.ui.col.toPlainText().strip()) > 0:
                self.ui.col.insertPlainText(",\n" + ag)
            else:
                self.ui.col.insertPlainText(ag)
            self.col_col.append(ag)
        elif self.evt.focus == "group":
            if len(self.ui.group.toPlainText().strip()) > 0:
                self.ui.group.insertPlainText(", " + ag)
            else:
                self.ui.group.insertPlainText(ag)
        elif self.evt.focus == "order":
            if len(self.ui.order.toPlainText().strip()) > 0:
                self.ui.order.insertPlainText(", " + ag)
            else:
                self.ui.order.insertPlainText(ag)

        self.ui.columns.setCurrentIndex(0)
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:35,代码来源:dlg_query_builder.py

示例7: okPressed

 def okPressed(self):
     self.alg = self.createAlgorithm()
     if self.alg is not None:
         self.close()
     else:
         QMessageBox.warning(self, self.tr('Unable to add algorithm'),
                             self.tr('Wrong or missing parameter values'))
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:7,代码来源:ModelerParametersDialog.py

示例8: openModel

    def openModel(self):
        filename = unicode(QFileDialog.getOpenFileName(self,
                                                       self.tr('Open Model'), ModelerUtils.modelsFolder(),
                                                       self.tr('Processing models (*.model *.MODEL)')))
        if filename:
            try:
                alg = ModelerAlgorithm.fromFile(filename)
                self.alg = alg
                self.alg.setModelerView(self)
                self.textGroup.setText(alg.group)
                self.textName.setText(alg.name)
                self.repaintModel()

                self.view.centerOn(0, 0)
                self.hasChanged = False
            except WrongModelException as e:
                ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
                                       self.tr('Could not load model %s\n%s') % (filename, e.msg))
                QMessageBox.critical(self, self.tr('Could not open model'),
                                     self.tr('The selected model could not be loaded.\n'
                                             'See the log for more information.'))
            except Exception as e:
                ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
                                       self.tr('Could not load model %s\n%s') % (filename, e.args[0]))
                QMessageBox.critical(self, self.tr('Could not open model'),
                                     self.tr('The selected model could not be loaded.\n'
                                             'See the log for more information.'))
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:27,代码来源:ModelerDialog.py

示例9: currentColumn

 def currentColumn(self):
     """ returns row index of selected column """
     sel = self.viewFields.selectionModel()
     indexes = sel.selectedRows()
     if len(indexes) == 0:
         QMessageBox.information(self, self.tr("DB Manager"), self.tr("nothing selected"))
         return -1
     return indexes[0].row()
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:8,代码来源:dlg_table_properties.py

示例10: runAction

    def runAction(self, action):
        action = unicode(action)

        if action.startswith("rows/"):
            if action == "rows/count":
                self.refreshRowCount()
                return True

        elif action.startswith("triggers/"):
            parts = action.split('/')
            trigger_action = parts[1]

            msg = QApplication.translate("DBManagerPlugin", "Do you want to %s all triggers?") % trigger_action
            QApplication.restoreOverrideCursor()
            try:
                if QMessageBox.question(None, QApplication.translate("DBManagerPlugin", "Table triggers"), msg,
                                        QMessageBox.Yes | QMessageBox.No) == QMessageBox.No:
                    return False
            finally:
                QApplication.setOverrideCursor(Qt.WaitCursor)

            if trigger_action == "enable" or trigger_action == "disable":
                enable = trigger_action == "enable"
                self.emitAboutToChange()
                self.database().connector.enableAllTableTriggers(enable, (self.schemaName(), self.name))
                self.refreshTriggers()
                return True

        elif action.startswith("trigger/"):
            parts = action.split('/')
            trigger_name = parts[1]
            trigger_action = parts[2]

            msg = QApplication.translate("DBManagerPlugin", "Do you want to %s trigger %s?") % (
                trigger_action, trigger_name)
            QApplication.restoreOverrideCursor()
            try:
                if QMessageBox.question(None, QApplication.translate("DBManagerPlugin", "Table trigger"), msg,
                                        QMessageBox.Yes | QMessageBox.No) == QMessageBox.No:
                    return False
            finally:
                QApplication.setOverrideCursor(Qt.WaitCursor)

            if trigger_action == "delete":
                self.emitAboutToChange()
                self.database().connector.deleteTableTrigger(trigger_name, (self.schemaName(), self.name))
                self.refreshTriggers()
                return True

            elif trigger_action == "enable" or trigger_action == "disable":
                enable = trigger_action == "enable"
                self.emitAboutToChange()
                self.database().connector.enableTableTrigger(trigger_name, enable, (self.schemaName(), self.name))
                self.refreshTriggers()
                return True

        return False
开发者ID:boggins,项目名称:QGIS,代码行数:57,代码来源:plugin.py

示例11: accept

 def accept(self):
     try:
         self.value = float(eval(unicode(self.leFormula.text())))
         if self.isInteger:
             self.value = int(round(self.value))
         QDialog.accept(self)
     except:
         QMessageBox.critical(self, self.tr('Wrong expression'),
                              self.tr('The expression entered is not correct'))
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:9,代码来源:NumberInputDialog.py

示例12: createTable

    def createTable(self):
        """ create table with chosen fields, optionally add a geometry column """
        if not self.hasSchemas:
            schema = None
        else:
            schema = unicode(self.cboSchema.currentText())
            if len(schema) == 0:
                QMessageBox.information(self, self.tr("DB Manager"), self.tr("select schema!"))
                return

        table = unicode(self.editName.text())
        if len(table) == 0:
            QMessageBox.information(self, self.tr("DB Manager"), self.tr("enter table name!"))
            return

        m = self.fields.model()
        if m.rowCount() == 0:
            QMessageBox.information(self, self.tr("DB Manager"), self.tr("add some fields!"))
            return

        useGeomColumn = self.chkGeomColumn.isChecked()
        if useGeomColumn:
            geomColumn = unicode(self.editGeomColumn.text())
            if len(geomColumn) == 0:
                QMessageBox.information(self, self.tr("DB Manager"), self.tr("set geometry column name"))
                return

            geomType = self.GEOM_TYPES[self.cboGeomType.currentIndex()]
            geomDim = self.spinGeomDim.value()
            try:
                geomSrid = int(self.editGeomSrid.text())
            except ValueError:
                geomSrid = 0
            useSpatialIndex = self.chkSpatialIndex.isChecked()

        flds = m.getFields()
        pk_index = self.cboPrimaryKey.currentIndex()
        if pk_index >= 0:
            flds[pk_index].primaryKey = True

        # commit to DB
        QApplication.setOverrideCursor(Qt.WaitCursor)
        try:
            if not useGeomColumn:
                self.db.createTable(table, flds, schema)
            else:
                geom = geomColumn, geomType, geomSrid, geomDim, useSpatialIndex
                self.db.createVectorTable(table, flds, geom, schema)

        except (ConnectionError, DbError) as e:
            DlgDbError.showError(e, self)
            return

        finally:
            QApplication.restoreOverrideCursor()

        QMessageBox.information(self, self.tr("Good"), self.tr("everything went fine"))
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:57,代码来源:dlg_create_table.py

示例13: deleteField

    def deleteField(self):
        """ delete selected field """
        row = self.selectedField()
        if row is None:
            QMessageBox.information(self, self.tr("DB Manager"), self.tr("no field selected"))
        else:
            self.fields.model().removeRows(row, 1)

        self.updatePkeyCombo()
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:9,代码来源:dlg_create_table.py

示例14: activateProvider

 def activateProvider(self, providerName):
     name = 'ACTIVATE_' + providerName.upper().replace(' ', '_')
     ProcessingConfig.setSettingValue(name, True)
     self.fillTree()
     self.textChanged()
     self.showDisabled()
     provider = Processing.getProviderFromName(providerName)
     if not provider.canBeActivated():
         QMessageBox.warning(self, "Activate provider",
                             "The provider has been activated, but it might need additional configuration.")
开发者ID:MrBenjaminLeb,项目名称:QGIS,代码行数:10,代码来源:ProcessingToolbox.py

示例15: execute

 def execute(self):
     f = os.path.join(FusionUtils.FusionPath(), 'pdq.exe')
     if os.path.exists(f):
         subprocess.Popen(f)
     else:
         QMessageBox.critical(None,
                              self.tr('Unable to open viewer'),
                              self.tr('The current Fusion folder does not contain the '
                                      'viewer executable.\nPlease check the configuration '
                                      'in the Processing settings dialog.'))
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:10,代码来源:OpenViewerAction.py


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