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.
Solved! Go to Solution.
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.
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.
@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}