I am writing a Python toolbox with (among other) 3 parameters: 2 boolean (check boxes) and 1 string. The string parameter's properties depends on the 2 booleans' value:
If at least the first boolean is true (box checked), the string (defined initially as disabled and optional) must be set to enabled and required.
If only the second boolean is true, the string must remain disabled and optional.
The following code works when opening the tool's interface (string parameter is disabled and optional) and checking the first boolean (string becomes enabled and required). But if I then uncheck it, the string parameter remains enabled and required. How do I make sure my tool checks the state of the boolean parameters at all times?
Working the other way round (string initially enabled and required and changing its state if the booleans are altered) would be fine too.
def updateParameters(self, params):
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a parameter
has been changed."""
if params[1].altered: # first boolean parameter
if params[1].value == 1:
params[8].enabled = 1 # string parameter
params[8].parameterType = "Optional"