Skip to main content
Tweeted twitter.com/StackGIS/status/1100183767740755968
deleted 57 characters in body; edited tags; edited title
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

Change Changing parameter values according to other parameter choice in Processing script using QGIS 3?

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
    )
)

Hoping to explain the problem right.

Thanks to all

Change parameter values according to other parameter choice in Processing script QGIS 3

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
    )
)

Hoping to explain the problem right.

Thanks to all

Changing parameter values according to other parameter choice in Processing script using QGIS 3?

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
    )
)
Source Link
matteo
  • 3.3k
  • 2
  • 24
  • 48

Change parameter values according to other parameter choice in Processing script QGIS 3

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
    )
)

Hoping to explain the problem right.

Thanks to all