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


Python QMessageBox.warning方法代码示例

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


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

示例1: okPressed

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

示例2: execute

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

示例3: batchFinished

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

示例4: setParamValues

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

示例5: activateAlgorithm

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

示例6: activateProvider

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

示例7: navigate

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import warning [as 别名]
    def navigate(self):
        """manage navigation / paging"""

        caller = self.sender().objectName()

        if caller == 'btnFirst':
            self.startfrom = 0
        elif caller == 'btnLast':
            self.startfrom = self.catalog.results['matches'] - self.maxrecords
        elif caller == 'btnNext':
            self.startfrom += self.maxrecords
            if self.startfrom >= self.catalog.results["matches"]:
                msg = self.tr('End of results. Go to start?')
                res = QMessageBox.information(self, self.tr('Navigation'),
                                              msg,
                                              (QMessageBox.Ok |
                                               QMessageBox.Cancel))
                if res == QMessageBox.Ok:
                    self.startfrom = 0
                else:
                    return
        elif caller == "btnPrev":
            self.startfrom -= self.maxrecords
            if self.startfrom <= 0:
                msg = self.tr('Start of results. Go to end?')
                res = QMessageBox.information(self, self.tr('Navigation'),
                                              msg,
                                              (QMessageBox.Ok |
                                               QMessageBox.Cancel))
                if res == QMessageBox.Ok:
                    self.startfrom = (self.catalog.results['matches'] -
                                      self.maxrecords)
                else:
                    return

        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))

        try:
            self.catalog.getrecords2(constraints=self.constraints,
                                     maxrecords=self.maxrecords,
                                     startposition=self.startfrom, esn='full')
        except ExceptionReport as err:
            QApplication.restoreOverrideCursor()
            QMessageBox.warning(self, self.tr('Search error'),
                                self.tr('Search error: %s') % err)
            return
        except Exception as err:
            QApplication.restoreOverrideCursor()
            QMessageBox.warning(self, self.tr('Connection error'),
                                self.tr('Connection error: %s') % err)
            return

        QApplication.restoreOverrideCursor()

        self.display_results()
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:57,代码来源:maindialog.py

示例8: okPressed

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import warning [as 别名]
 def okPressed(self):
     if self.textTableName.text().strip() == "":
         self.textTableName.setStyleSheet("QLineEdit{background: yellow}")
         return
     item = self.treeConnections.currentItem()
     if isinstance(item, ConnectionItem):
         QMessageBox.warning(self, "Wrong selection", "Select a schema item in the tree")
         return
     self.schema = item.text(0)
     self.table = self.textTableName.text().strip()
     self.connection = item.parent().text(0)
     self.close()
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:14,代码来源:PostgisTableSelector.py

示例9: runModel

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import warning [as 别名]
    def runModel(self):
        if len(self.alg.algs) == 0:
            QMessageBox.warning(self, self.tr('Empty model'),
                                self.tr("Model doesn't contains any algorithms and/or "
                                        "parameters and can't be executed"))
            return

        if self.alg.provider is None:
            # Might happen if model is opened from modeler dialog
            self.alg.provider = ModelerUtils.providers['model']
        alg = self.alg.getCopy()
        dlg = AlgorithmDialog(alg)
        dlg.exec_()
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:15,代码来源:ModelerDialog.py

示例10: checkLayer

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import warning [as 别名]
    def checkLayer(self):
        layerList = []

        layerMap = QgsMapLayerRegistry.instance().mapLayers()
        for name, layer in layerMap.iteritems():
            if layer.type() == QgsMapLayer.RasterLayer:
                layerList.append(unicode(layer.source()))

        if unicode(self.inputFileEdit.text()) in layerList:
            QMessageBox.warning(self, self.tr("Assign projection"), self.tr("This raster already found in map canvas"))
            return

        self.onRun()
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:15,代码来源:doProjection.py

示例11: importLayer

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import warning [as 别名]
    def importLayer(self, layerType, providerKey, layerName, uriString, parent):
        global isImportVectorAvail

        if not isImportVectorAvail:
            return False

        if layerType == 'raster':
            return False  # not implemented yet
            inLayer = QgsRasterLayer(uriString, layerName, providerKey)
        else:
            inLayer = QgsVectorLayer(uriString, layerName, providerKey)

        if not inLayer.isValid():
            # invalid layer
            QMessageBox.warning(None, self.tr("Invalid layer"), self.tr("Unable to load the layer %s") % inLayer.name())
            return False

        # retrieve information about the new table's db and schema
        outItem = parent.internalPointer()
        outObj = outItem.getItemData()
        outDb = outObj.database()
        outSchema = None
        if isinstance(outItem, SchemaItem):
            outSchema = outObj
        elif isinstance(outItem, TableItem):
            outSchema = outObj.schema()

        # toIndex will point to the parent item of the new table
        toIndex = parent
        if isinstance(toIndex.internalPointer(), TableItem):
            toIndex = toIndex.parent()

        if inLayer.type() == inLayer.VectorLayer:
            # create the output uri
            schema = outSchema.name if outDb.schemas() is not None and outSchema is not None else ""
            pkCol = geomCol = ""

            # default pk and geom field name value
            if providerKey in ['postgres', 'spatialite']:
                inUri = QgsDataSourceURI(inLayer.source())
                pkCol = inUri.keyColumn()
                geomCol = inUri.geometryColumn()

            outUri = outDb.uri()
            outUri.setDataSource(schema, layerName, geomCol, "", pkCol)

            self.importVector.emit(inLayer, outDb, outUri, toIndex)
            return True

        return False
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:52,代码来源:db_model.py

示例12: removeElement

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import warning [as 别名]
 def removeElement(self):
     if isinstance(self.element, ModelerParameter):
         if not self.model.removeParameter(self.element.param.name):
             QMessageBox.warning(None, 'Could not remove element',
                                 'Other elements depend on the selected one.\n'
                                 'Remove them before trying to remove it.')
         else:
             self.model.updateModelerView()
     elif isinstance(self.element, Algorithm):
         if not self.model.removeAlgorithm(self.element.name):
             QMessageBox.warning(None, 'Could not remove element',
                                 'Other elements depend on the selected one.\n'
                                 'Remove them before trying to remove it.')
         else:
             self.model.updateModelerView()
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:17,代码来源:ModelerGraphicItem.py

示例13: finished

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import warning [as 别名]
    def finished(self):
        outFn = self.getOutputFileName()
        if self.needOverwrite:
            oldFile = QFile(outFn)
            newFile = QFile(self.tempFile)
            if oldFile.remove():
                newFile.rename(outFn)

        fileInfo = QFileInfo(outFn)
        if fileInfo.exists():
            if self.base.loadCheckBox.isChecked():
                self.addLayerIntoCanvas(fileInfo)
            QMessageBox.information(self, self.tr("Finished"), self.tr("Processing completed."))
        else:
            QMessageBox.warning(self, self.tr("Warning"), self.tr("{0} not created.").format(outFn))
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:17,代码来源:doProjection.py

示例14: accept

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import warning [as 别名]
    def accept(self):
        for setting in self.items.keys():
            if isinstance(setting.value, bool):
                setting.setValue(self.items[setting].checkState() == Qt.Checked)
            else:
                try:
                    setting.setValue(unicode(self.items[setting].text()))
                except ValueError as e:
                    QMessageBox.warning(self, self.tr('Wrong value'),
                                        self.tr('Wrong value for parameter "%s":\n\n%s' % (setting.description, unicode(e))))
                    return
            setting.save()
        Processing.updateAlgsList()
        updateMenus()

        QDialog.accept(self)
开发者ID:lidi100,项目名称:QGIS,代码行数:18,代码来源:ConfigDialog.py

示例15: load

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import warning [as 别名]
    def load(self, items):
        """load connections"""

        self.settings.beginGroup('/MetaSearch/')
        keys = self.settings.childGroups()
        self.settings.endGroup()

        exml = etree.parse(self.filename).getroot()

        for csw in exml.findall('csw'):
            conn_name = csw.attrib.get('name')

            # process only selected connections
            if conn_name not in items:
                continue

            # check for duplicates
            if conn_name in keys:
                label = self.tr('File %s exists. Overwrite?') % conn_name
                res = QMessageBox.warning(self, self.tr('Loading Connections'),
                                          label,
                                          QMessageBox.Yes | QMessageBox.No)
                if res != QMessageBox.Yes:
                    continue

            # no dups detected or overwrite is allowed
            url = '/MetaSearch/%s/url' % conn_name
            self.settings.setValue(url, csw.attrib.get('url'))
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:30,代码来源:manageconnectionsdialog.py


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