Select to view content in your preferred language

Custom Buttons for Custom Python Tools

544
1
10-04-2024 01:17 PM
Status: Closed
Labels (1)
jvanlaan
Emerging Contributor

It would amazing if the custom Python toolbox in ArcGIS Pro would allow us to define one (or more) custom buttons for our Python tools. We could initialize our button in the tools init, or perhaps a getButtonInfo function could be added to the tool lifecycle. From there, we could return a button definition object that includes things likes button_text, button_icon (perhaps from a predefined list of icons), etc. Then an addition buttonClicked function could be added to the tool that accepts parameters, messages, and some reference to the button clicked (if more than one are allowed). This would allow us to wire up additional behaviors that we may want to occur before execution of a given tool. See attached screenshot for example taken from the a built-in sharing tool in ArcGIS Pro.

1 Comment
HannesZiegler
Status changed to: Closed

Thank you for submitting your idea to support custom buttons in script tools. We appreciate your suggestion and the time you took to provide detailed feedback. However, tools are intended to be single-responsibility functions. They receive a set of inputs, perform validation, process the data, and produce some sort of result. This allows tools to act as building blocks in a workflow, such that multiple tools can be chained together to perform more complex processing. They can be thought of as the functionality behind a single button. Adding custom buttons within a tool would go counter to this structure, as it would introduce possible side-effects outside of the main purpose of the tool. If some preprocessing needs to occur that might otherwise be triggered by a custom button, it should be implemented as a separate tool.

If you need to develop custom UI, .NET add-ins are the way to go. Buttons on the add-in could even call a script tool behind the scenes, so you could develop your (pre)processing functionality as script tools and then tie them together with a custom UI frontend.

Please note that our 2k+ geoprocessing tools all follow the get inputs and run paradigm described above. The example screenshot (I believe it is of export package) is actually implemented as a separate Pane, not a geoprocessing tool (there is a geoprocessing tool by the same name, but it does not have custom buttons, just the Run button).

For these reasons, we will not be implementing this idea at this time. Thank you again for your contribution and understanding.