12

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
    )
)
1
  • Has this issue been resolved or is there an alternative? This feature would be very useful.
    – ZKB
    Commented Feb 16, 2023 at 10:18

1 Answer 1

7

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)

1
  • 1
    Do you know if theres been an update or is it still not possible?
    – Freddy94
    Commented Jun 18 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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