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


Python QMessageBox.critical方法代码示例

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


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

示例1: createGeomColumn

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import critical [as 别名]
    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,代码行数:28,代码来源:dlg_add_geometry_column.py

示例2: openModel

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import critical [as 别名]
    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,代码行数:29,代码来源:ModelerDialog.py

示例3: accept

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import critical [as 别名]
 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,代码行数:11,代码来源:NumberInputDialog.py

示例4: execute

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import critical [as 别名]
 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,代码行数:12,代码来源:OpenViewerAction.py

示例5: onOK

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import critical [as 别名]
    def onOK(self):
        """ first check whether everything's fine """
        fld = self.getField(True)  # don't change the original copy
        if fld.name == "":
            QMessageBox.critical(self, self.tr("DB Manager"), self.tr("field name must not be empty"))
            return
        if fld.dataType == "":
            QMessageBox.critical(self, self.tr("DB Manager"), self.tr("field type must not be empty"))
            return

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

示例6: createIndex

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import critical [as 别名]
    def createIndex(self):
        idx = self.getIndex()
        if idx.name == "":
            QMessageBox.critical(self, self.tr("Error"), self.tr("Please enter some name for the index"))
            return

        # now create the index
        QApplication.setOverrideCursor(Qt.WaitCursor)
        try:
            self.table.addIndex(idx)
        except DbError as e:
            DlgDbError.showError(e, self)
            return
        finally:
            QApplication.restoreOverrideCursor()

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

示例7: load

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import critical [as 别名]
    def load(self):
        filename = unicode(QFileDialog.getOpenFileName(self,
                                                       self.tr('Open batch'), None,
                                                       self.tr('JSON files (*.json)')))
        if filename:
            with open(filename) as f:
                values = json.load(f)
        else:
            # If the user clicked on the cancel button.
            return

        self.tblParameters.setRowCount(0)
        try:
            for row, alg in enumerate(values):
                self.addRow()
                params = alg[self.PARAMETERS]
                outputs = alg[self.OUTPUTS]
                column = 0
                for param in self.alg.parameters:
                    if param.hidden:
                        continue
                    widget = self.tblParameters.cellWidget(row, column)
                    if param.name in params:
                        value = params[param.name]
                        self.setValueInWidget(widget, value)
                    column += 1

                for out in self.alg.outputs:
                    if out.hidden:
                        continue
                    widget = self.tblParameters.cellWidget(row, column)
                    if out.name in outputs:
                        value = outputs[out.name]
                        self.setValueInWidget(widget, value)
                    column += 1
        except TypeError:
            QMessageBox.critical(
                self,
                self.tr('Error'),
                self.tr('An error occured while reading your file.'))
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:42,代码来源:BatchPanel.py

示例8: accept

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import critical [as 别名]
    def accept(self):
        self.settings.setValue("/Processing/dialogBase", self.saveGeometry())

        checkCRS = ProcessingConfig.getSetting(ProcessingConfig.WARN_UNMATCHING_CRS)
        try:
            self.setParamValues()
            if checkCRS and not self.alg.checkInputCRS():
                reply = QMessageBox.question(self, self.tr("Unmatching CRS's"),
                                             self.tr('Layers do not all use the same CRS. This can '
                                                     'cause unexpected results.\nDo you want to '
                                                     'continue?'),
                                             QMessageBox.Yes | QMessageBox.No,
                                             QMessageBox.No)
                if reply == QMessageBox.No:
                    return
            msg = self.alg._checkParameterValuesBeforeExecuting()
            if msg:
                QMessageBox.warning(
                    self, self.tr('Unable to execute algorithm'), msg)
                return
            self.btnRun.setEnabled(False)
            self.btnClose.setEnabled(False)
            buttons = self.mainWidget.iterateButtons
            self.iterateParam = None

            for i in range(len(buttons.values())):
                button = buttons.values()[i]
                if button.isChecked():
                    self.iterateParam = buttons.keys()[i]
                    break

            self.progressBar.setMaximum(0)
            self.lblProgress.setText(self.tr('Processing algorithm...'))
            # Make sure the Log tab is visible before executing the algorithm
            try:
                self.tabWidget.setCurrentIndex(1)
                self.repaint()
            except:
                pass

            QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))

            self.setInfo(
                self.tr('<b>Algorithm %s starting...</b>') % self.alg.name)

            if self.iterateParam:
                if runalgIterating(self.alg, self.iterateParam, self):
                    self.finish()
                else:
                    QApplication.restoreOverrideCursor()
                    self.resetGUI()
            else:
                command = self.alg.getAsCommand()
                if command:
                    ProcessingLog.addToLog(
                        ProcessingLog.LOG_ALGORITHM, command)
                if runalg(self.alg, self):
                    self.finish()
                else:
                    QApplication.restoreOverrideCursor()
                    self.resetGUI()
        except AlgorithmDialogBase.InvalidParameterValue as e:
            try:
                self.buttonBox.accepted.connect(lambda:
                                                e.widget.setPalette(QPalette()))
                palette = e.widget.palette()
                palette.setColor(QPalette.Base, QColor(255, 255, 0))
                e.widget.setPalette(palette)
                self.lblProgress.setText(
                    self.tr('<b>Missing parameter value: %s</b>') % e.parameter.description)
                return
            except:
                QMessageBox.critical(self,
                                     self.tr('Unable to execute algorithm'),
                                     self.tr('Wrong or missing parameter values'))
开发者ID:Clayton-Davis,项目名称:QGIS,代码行数:77,代码来源:AlgorithmDialog.py

示例9: error

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import critical [as 别名]
 def error(self, text):
     QMessageBox.critical(self, "Error", text)
     ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, text)
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:5,代码来源:FieldsCalculatorDialog.py

示例10: getArguments

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import critical [as 别名]
    def getArguments(self):
        arguments = []
        if self.targetSRSCheck.isChecked() and self.targetSRSEdit.text():
            arguments.append("-a_srs")
            arguments.append(self.targetSRSEdit.text())
        if self.creationOptionsGroupBox.isChecked():
            for opt in self.creationOptionsWidget.options():
                arguments.extend(["-co", opt])
        if self.outsizeCheck.isChecked() and self.outsizeSpin.value() != 100:
            arguments.append("-outsize")
            arguments.append(self.outsizeSpin.text())
            arguments.append(self.outsizeSpin.text())
        if self.expandCheck.isChecked():
            arguments.append("-expand")
            arguments.append(self.expand_method[self.expandCombo.currentIndex()])
        if self.nodataCheck.isChecked():
            arguments.append("-a_nodata")
            arguments.append(unicode(self.nodataSpin.value()))
        if self.sdsCheck.isChecked():
            arguments.append("-sds")
        if self.srcwinCheck.isChecked() and self.srcwinEdit.text():
            coordList = self.srcwinEdit.text().split()  # split the string on whitespace(s)
            if len(coordList) == 4 and coordList[3]:
                try:
                    for x in coordList:
                        int(x)
                except ValueError:
                    #print "Coordinates must be integer numbers."
                    QMessageBox.critical(self, self.tr("Translate - srcwin"), self.tr("Image coordinates (pixels) must be integer numbers."))
                else:
                    arguments.append("-srcwin")
                    for x in coordList:
                        arguments.append(x)
        if self.prjwinCheck.isChecked() and self.prjwinEdit.text():
            coordList = self.prjwinEdit.text().split()  # split the string on whitespace(s)
            if len(coordList) == 4 and coordList[3]:
                try:
                    for x in coordList:
                        float(x)
                except ValueError:
                    #print "Coordinates must be integer numbers."
                    QMessageBox.critical(self, self.tr("Translate - prjwin"), self.tr("Image coordinates (geographic) must be numbers."))
                else:
                    arguments.append("-projwin")
                    for x in coordList:
                        arguments.append(x)
        if self.isBatchEnabled():
            if self.formatCombo.currentIndex() != 0:
                arguments.append("-of")
                arguments.append(Utils.fillRasterOutputFormat(self.formatCombo.currentText()))
                return arguments
            else:
                return arguments

        outputFn = self.getOutputFileName()
        if outputFn:
            arguments.append("-of")
            arguments.append(self.outputFormat)
        arguments.append(self.getInputFileName())
        arguments.append(outputFn)

        # set creation options filename/layer for validation
        if self.inSelector.layer():
            self.creationOptionsWidget.setRasterLayer(self.inSelector.layer())
        else:
            self.creationOptionsWidget.setRasterFileName(self.getInputFileName())

        return arguments
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:70,代码来源:doTranslate.py


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