7

I couldn't find anything about this problem.

Suppose to have the first parameters in a Processing script defined as an Enum:

   self.addParameter(
        QgsProcessingParameterEnum(
            self.CHOICE,
            self.tr('Choose the parameter'),
            ['param1', 'param2']
        )
)

While the second one as a number:

self.addParameter(
    QgsProcessingParameterNumber(
        name=self.VALUE,
        description=self.tr('My value'),
        type=QgsProcessingParameterNumber.Double,
        defaultValue=40,
        optional=False,
        minValue=0,
        maxValue=100
    )
)

Is it possible to change the minValue, maxValue, description, ecc.. of the second parameter depending on the first or second choice of the first parameter already in the GUI?

e.g. if the user choose param1 then the second parameter should become:

self.addParameter(
    QgsProcessingParameterNumber(
        name=self.VALUE,
        description=self.tr('My value'),
        type=QgsProcessingParameterNumber.Double,
        defaultValue=40,
        optional=False,
        minValue=0,
        maxValue=100
    )
)

while if he choose param2 it should became:

self.addParameter(
    QgsProcessingParameterNumber(
        name=self.VALUE,
        description=self.tr('My AWESOME value'),
        type=QgsProcessingParameterNumber.Double,
        defaultValue=0,
        optional=False,
        minValue=50,
        maxValue=500
    )
)
5

No, there's no support for this in existing QGIS versions (<= 3.8). You'd need to address this at runtime, and add a check that the evaluated parameter value falls into the acceptable range (raising a QgsProcessingException otherwise)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.