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


Python ParameterCrs.setFlags方法代码示例

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


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

示例1: ModelerParameterDefinitionDialog

# 需要导入模块: from processing.core.parameters import ParameterCrs [as 别名]
# 或者: from processing.core.parameters.ParameterCrs import setFlags [as 别名]

#.........这里部分代码省略.........
        self.verticalLayout.addWidget(self.buttonBox)

        self.setLayout(self.verticalLayout)

    def okPressed(self):
        description = str(self.nameTextBox.text())
        if description.strip() == '':
            QMessageBox.warning(self, self.tr('Unable to define parameter'),
                                self.tr('Invalid parameter name'))
            return
        if self.param is None:
            validChars = \
                'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
            safeName = ''.join(c for c in description if c in validChars)
            name = safeName.lower()
            i = 2
            while name in self.alg.inputs:
                name = safeName.lower() + str(i)
        else:
            name = self.param.name()
        if (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_BOOLEAN or
                isinstance(self.param, ParameterBoolean)):
            self.param = ParameterBoolean(name, description, self.state.isChecked())
        elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_TABLE_FIELD or
              isinstance(self.param, ParameterTableField)):
            if self.parentCombo.currentIndex() < 0:
                QMessageBox.warning(self, self.tr('Unable to define parameter'),
                                    self.tr('Wrong or missing parameter values'))
                return
            parent = self.parentCombo.currentData()
            datatype = self.datatypeCombo.currentData()
            self.param = ParameterTableField(name, description, parent, datatype, multiple=self.multipleCheck.isChecked())
        elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_RASTER or
                isinstance(self.param, ParameterRaster)):
            self.param = ParameterRaster(
                name, description)
        elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_TABLE or
                isinstance(self.param, ParameterTable)):
            self.param = ParameterTable(
                name, description)
        elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_VECTOR or
                isinstance(self.param, ParameterVector)):
            self.param = ParameterVector(
                name, description,
                [self.shapetypeCombo.currentIndex() - 1])
        elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_MULTIPLE or
                isinstance(self.param, ParameterMultipleInput)):
            self.param = ParameterMultipleInput(
                name, description,
                self.datatypeCombo.currentIndex() - 1)
        elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_NUMBER or
                isinstance(self.param, ParameterNumber)):
            try:
                vmin = self.minTextBox.text().strip()
                if vmin == '':
                    vmin = None
                else:
                    vmin = float(vmin)
                vmax = self.maxTextBox.text().strip()
                if vmax == '':
                    vmax = None
                else:
                    vmax = float(vmax)
                self.param = ParameterNumber(name, description, vmin, vmax,
                                             str(self.defaultTextBox.text()))
            except:
                QMessageBox.warning(self, self.tr('Unable to define parameter'),
                                    self.tr('Wrong or missing parameter values'))
                return
        elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_EXPRESSION or
                isinstance(self.param, ParameterExpression)):
            parent = self.parentCombo.currentData()
            self.param = ParameterExpression(name, description,
                                             default=str(self.defaultEdit.expression()),
                                             parent_layer=parent)
        elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_STRING or
                isinstance(self.param, ParameterString)):
            self.param = ParameterString(name, description,
                                         str(self.defaultTextBox.text()))
        elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_EXTENT or
                isinstance(self.param, ParameterExtent)):
            self.param = ParameterExtent(name, description)
        elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_FILE or
                isinstance(self.param, ParameterFile)):
            isFolder = self.fileFolderCombo.currentIndex() == 1
            self.param = ParameterFile(name, description, isFolder=isFolder)
        elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_POINT or
                isinstance(self.param, ParameterPoint)):
            self.param = ParameterPoint(name, description,
                                        str(self.defaultTextBox.text()))
        elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_CRS or
                isinstance(self.param, ParameterCrs)):
            self.param = ParameterCrs(name, description, default=self.selector.crs().authid())
        if not self.requiredCheck.isChecked():
            self.param.setFlags(self.param.flags() | QgsProcessingParameterDefinition.FlagOptional)
        self.close()

    def cancelPressed(self):
        self.param = None
        self.close()
开发者ID:rskelly,项目名称:QGIS,代码行数:104,代码来源:ModelerParameterDefinitionDialog.py


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