Select to view content in your preferred language

Value List Filter - Aliases/Text

500
2
Jump to solution
10-18-2022 02:33 AM
Labels (2)
RichardHowe
Frequent Contributor

If I am creating a value list filter in a toolbox tool for the user to select (in this case pointing at urls) is there a way for the text they select from in the tool GUI dropdown to be different from the values in the list that are fed to the script?

I want to give the user a human readable option (which I also need to utilize later in the script for naming outputs), rather than the (meaningless to them) url.

0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

If a selection is made from the value list, it will be a parameter for the tool.  From the selected value, why not use a dictionary to extract what you want.


... sort of retired...

View solution in original post

2 Replies
DanPatterson
MVP Esteemed Contributor

If a selection is made from the value list, it will be a parameter for the tool.  From the selected value, why not use a dictionary to extract what you want.


... sort of retired...
RichardHowe
Frequent Contributor

@DanPatterson Now why didn't that occur to me 🤦🏻‍ Thanks!

Works like a charm. For anybody that happens upon this. A dictionary where each of the keys is one of the value list inputs and each of the values is the url  (or whatever you want to script to actually use) is the way to go.

Define the dictionary in the script and use similar code to that below to compare your inputs and generate a new dictionary within the script, which allows you to reference both the key and value furter on in the script.


 

URL_dict = {1:'www.esri.com'}
inputs = arcpy.GetParameter(1)
for i in inputs:
    if i in URL_dict:
        tool_dict = {i: URL_dict[i] for i in inputs if site in URL_dict}

 

 

 




0 Kudos