Select to view content in your preferred language

Custom Ribbon Button to Python Code

358
3
10-23-2025 08:22 AM
WrightDrew
New Contributor

Hello! I have created a Python File that automatically runs a update of the current map the user is looking at to the AGOL.  However, I would like to add this as a button in their custom ribbons so they dont have to run a seperate file each time.  Does anyone know how to do this?  Below is the path of the py file I am hoping to run.

 

C:\GIS\Scripts\update_maps_fast.py

0 Kudos
3 Replies
DavidSolari
MVP Regular Contributor

There might be a way to hack a specific tool into a ribbon button, but odds are you'll have to bundle your toolbox into a Pro Addon using the SDK Documentation.

HaydenWelch
MVP Regular Contributor

Python buttons were dropped in the upgrade from ArcMap to ArcPro so as far as I know this is indeed the only way. You have to define the ribbon/tool using C# and a daml file then call the Python tool using the C# SDK.

It would be nice to have Python buttons back, since a lot of the time you don't need the baggage of the SDK to get what you need done and managing compiled extensions can be a pain.

HaydenWelch
MVP Regular Contributor

You can format your script to use the .pyt interface and import it as a Toolbox if you want. I do that for most of my scripts since I'm too lazy to maintain C# extensions lol.

Creating a new PYT toolbox 

 

If you don't have any parameters, you can usually just copy and paste most of your script into the execute method.

 

0 Kudos