Select to view content in your preferred language

Scripting tools (ATBX, PYT): Add Radio Buttons or Likert Scale

563
4
11-12-2024 09:29 AM
Status: Open
AlfredBaldenweck
MVP Regular Contributor

When creating tools, I often have different behavior in execution, based on what is essentially a toggle: If the value of Parameter1 equals "Do this", do this. If it's "Do that", do that.

For this to happen, I make heavy use of the parameter's filter list.

 

        MOVE_TOGG = arcpy.Parameter(displayName = "Did the things move?",
                                    name = "MOVE_TOGG",
                                    datatype = "GPString",
                                    parameterType = "Required",
                                    direction = "Input")
        # This is just an example, these are not actual values.
        MOVE_TOGG.filter.list = [("A and B did"),
                                 ("A did"),
                                 ("B did")
                                 ]

 

 

Another thing is that these toggles are frequently, if not always, required parameters.

What I would like is the ability to do this as a radio button-- One thing must be selected, but you see them all at once.

This would be great for "Do you want to save a copy to {location}? --> Yes, No".

Booleans don't work-- how is the user supposed to tell the difference between False and None if the checkbox looks the same? How do you ensure they actually answered the question?

Filter lists work, but the dropdown is kind of a lot anyway, and then if we have like 5 dropdowns, it's tiring. Being able to see all your choices at once and just click on the one you want would be great.

 

4 Comments
DuncanHornby

I don't think radio controls exist currently in the geoprocessing tool interface. There is this page that may be of interest to you where in a few cases you can choose an alternate interface for certain parameter types.

ShaunWalbridge
Status changed to: Needs Clarification

@AlfredBaldenweckThanks for your suggestion. Could you see if the existing Multivalue controls described in the parameter controls documentation allow you to do what you're looking for? Those seem to map most closely and would allow you to avoid the dropdown.

AlfredBaldenweck

Close but not quite. Using a multivalue would require me to add in additional validation to make sure that only one thing is selected. I'm looking for an "Either/or" situation, not an "And" situation. Radio Buttons are ideal because only one thing can be toggled at once.

ShaunWalbridge
Status changed to: Open

@AlfredBaldenweckOK. I think in that case, you can do it with validation code to modify the state to only support a single checked value and uncheck the other values when one of the values has been altered.

 

After some internal polling,  we think that we've been able to produce a wide variety of Geoprocessing tools with different interfaces without an explicit radio option, and without this mapping onto a broader need it isn't something we currently intend to offer. I'll leave this open for now to see if it attracts attention more broadly, but workarounds are the best short term bet in any case.