4

I'm trying to add a simple drop down menu in my python script tool that always has the same two options to choose from. From the list of parameter types, I haven't found a type that allows this kind of selection.

I've seen many questions answered about using the arcpy.SearchCursor function to search through a field and then use those attributes as the drop down menu options, but I just want to simply hard code two options.

I imagine I'd still use arcpy.GetParameterAsText for setting the menu selection to a variable in my script. But in terms of either hard coding the options into my script, or adding them right in the tool shell(?) I'm lost and haven't been able to find any info on this particular task.

enter image description here

1
  • 2
    #loveit great ui mockup.
    – KHibma
    Commented Mar 8, 2017 at 19:22

1 Answer 1

2

When you have attached your script to a tool, you can specify your parameters in the Tool properties.

One of the options for parameters is to set values that are displayed in a drop-down. These are not parameter types, but are rather found in the bottom Parameter Properties box under Filter > Value List

enter image description here

When you select this you'll be presented a dialog where you can populate your set values

enter image description here

Once these are set you can run your tool and the options will be shown in a drop-down

enter image description here

It is documented in Setting script tool parameters -> Filter

1
  • 1
    DUDE! Thank you! Wow, that's such a simple little process.
    – geominded
    Commented Mar 8, 2017 at 19:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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