How to disable a parameter in Python script tool window?

779
2
Jump to solution
07-29-2014 09:46 AM
MarAlcaraz
New Contributor II

Hi,

I'd like to offer to final users of a python script tool the option to work with a constant value (as double) or a raster dataset.

I've thought about defining 2 parameters ( double and raster dataset) but I dont know how to disable the parameter not selected by the user.

Is that possible? Is there other solutions?

Thanks in advance

1 Solution

Accepted Solutions
RussellBrennan
Esri Contributor

Mar,

Take a look at this topic, it describes how to perform the validation you are looking for.

Customizing Script tool behavior

The first example on this page shows you what you need to do in the updateParameters method:

def updateParameters(self):

  # If the option to use a weights file is selected (the user chose
  # "Get Spatial Weights From File"), enable the parameter for specifying 
  # the file, otherwise disable it
  #
  if self.params[3].value == "Get Spatial Weights From File":
   self.params[8].enabled = 1
  else:
   self.params[8].enabled = 0




You will want to change this slightly for your workflow.

View solution in original post

2 Replies
RussellBrennan
Esri Contributor

Mar,

Take a look at this topic, it describes how to perform the validation you are looking for.

Customizing Script tool behavior

The first example on this page shows you what you need to do in the updateParameters method:

def updateParameters(self):

  # If the option to use a weights file is selected (the user chose
  # "Get Spatial Weights From File"), enable the parameter for specifying 
  # the file, otherwise disable it
  #
  if self.params[3].value == "Get Spatial Weights From File":
   self.params[8].enabled = 1
  else:
   self.params[8].enabled = 0




You will want to change this slightly for your workflow.

MarAlcaraz
New Contributor II

Thanks Russell, I passed over the validation section!!!

0 Kudos