I am working on a python based script/tool. I would like to make use of drop down lists for several of the parameters. This is very easy to do if the lists are just plain old strings.

Does anyone know if it is possible to bind objects to this list and display a certain property? Objects will be very simple; just key-value pairs.

So, I would like to display the key and be able to access the value somewhere in the ToolValidator, or better yet access the ToolValidator class from the tool script itself?


Since you know that you can provide a potential list of acceptable values to a tool parameter, you could try using the selected value from the domain, as the key to a dictionary residing in your main script.

| improve this answer | |

Have your dictionary object contain a key of the same name in your drop down list.

If you're feeling adventurous, try creating a class with the default property __name__ set to the value you want to display in your drop down list. Though this is getting over complicated and not very pythonic, it might correctly bind to the drop down list and assess this default property and deliver you the functionality you want.

I say might. I have not tested this and am skewing programming idioms (I'm usually a .Net developer).

| improve this answer | |

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