1

I've got a script wherein I'd like to toggle (gray out) certain fields, unless a file has been specified.

Script

In the above image, I'd like Field A, B, and C to only be editable once a file has been selected in Input Worksheet. In updateParameters I've done the following, which doesn't seem to work:

  def updateParameters(self):
    if self.params[0].value:
        self.params[1].enabled == True
        self.params[2].enabled == True
        self.params[3].enabled == True
    else:
        self.params[1].enabled == False
        self.params[2].enabled == False
        self.params[3].enabled == False

I've tried using altered as well, nothing seems to work the way I'd like it to.

1

Try this:

  def updateParameters(self):
    if self.params[0].value and self.params[0].altered:
        self.params[1].enabled = True
        self.params[2].enabled = True
        self.params[3].enabled = True
    elif not self.params[0].value and self.params[0].altered:
        self.params[1].enabled = False
        self.params[2].enabled = False
        self.params[3].enabled = False

Two things:

  1. Check both if the parameter has value and it has been altered
  2. Assign the true and false, not check if it's equivalent or not (= vs ==)
1

With == you are asking if the enabled parameter is equal to True or False which makes no sense.

What you want to be doing is assigning the parameter True or False, in that case you use a single =.

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.