Custom toolbar that contains Python Scripts

4515
5
07-30-2015 01:36 PM
CoyPotts1
Occasional Contributor III

I have been trying to come up with a custom toolbar that incorporates some of the python scripts that I have created, but I can't seem to get ArcMap to save some of the customizations that I make to the toolbar.  I have created the custom toolbar, I made sure that the options to save customizations to the MXD were unchecked, and I added in a mix of standard tools as well as my python scripts.  I edited labels and images to a point where I was happy with it, saved the map and closed it.  None of the python scripts that I added in were saved in the toolbar.  The standard tools stayed, but all python scripts just don't show up on the toolbar, and are no longer visible in the Customize > Commands > GP Tools section. 

Can you incorporate python scripts in a toolbar without the use of any other code?  I'm not really sure why it even allows you to add a python script to a toolbar if it doesn't allow them to stay there after closing.  I deleted my Normal.mxt file and started from scratch with no luck.

Right now the scripts are stored within a toolbox on a shared drive so that we can all use them, which works, but I would like to create a toolbar if possible. 

Any suggestions?

Tags (1)
0 Kudos
5 Replies
PacoAlverez
New Contributor III

have you looked into creating add-ins.

Add-ins for ArcGIS Desktop 10 | ArcGIS Blog

CoyPotts1
Occasional Contributor III

I had not, but I was under the assumption that simply adding the python script to wthe toolbar as sufficient.  I'll look into creating add-ins and see if it is worth the effort for what we need. 

Thanks for the suggestion!

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

You may want to look at this discussion Re: Python add-ins vs. .NET add-ins?   I have some tips for getting going on python addins.  It's pretty fast and easy to setup if you get all your scripts loaded into a custom Toolbo (toolbox, not toolbar).  The outcome is an addin with a custom toolbar.

CoyPotts1
Occasional Contributor III

Rebecca, thanks for your input as well.  I'll have to look into following your procedure creating the python add-ins.  I think this is my preferred method, simply because I don't currently know a lot about .Net, so I would rather just stick to what I know for now. 

Thanks!

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

I never went the .net route either since I'm not fluent. I do have several python addins, some that are new and others that I'm currently updating.

One thing to keep in mind is that ArcGIS Pro cannot use Python addins.  However, and addin is just a zip file with the .esriaddin extension instead of .zip (that is, you can change the extension to .zip and unzip to view any of the addin files), so if you get an addin, you can usually unzip it and use the toolbox (if that is the source) directly in Pro.  If it's your own addin, you should be able to use the toolbox direct in Pro.

What I am finding right now though is the move from python 2.x to 3.x is causing a few issues....and Pro is much more strict in correct syntax (i.e. tabs OR spacing....not mixed)....Desktop is much more forgiving.   So, keeping everything clean from the get go helps.   I'll probably summarize some and share some of my tips at some point when I figure out the code for being able to test and have it work for both.

Have fun....(I really like python addins!)