Python Add-In Button Issues

12315
28
08-11-2015 01:16 PM
CoyPotts1
Occasional Contributor III

@

I'm tagging Rebecca because of the conversation here: Custom toolbar that contains Python Scripts

I have been playing with the Python Add-In Wizard, and I have created a toolbar with some menus and buttons.  I am having trouble getting the buttons to work, though.  I've followed Rebecca's instructions (here: Python add-ins vs. .NET add-ins?​), as well as the attached PDF to try and use an existing python script within my toolbox, but the button just shows up as missing when I install the add-in and run ArcMap.  I've even tried pasting the entire code from the script directly into the onClick function, and that just does the same thing.

Is this a common problem?  Is this indicative of a common issue, or could it be a vague error that would be harder to diagnose...?  I read somewhere that the missing designation could mean that there is some sort of syntax error in the code, but the scripts work on their own...just not whenever I try to associate them with a button on the custom add-in toolbar.

Thanks you!

28 Replies
RebeccaStrauch__GISP
MVP Emeritus

If you hover over my avatar and wait for the pop-up, you should see the option to "follow".  If you follow me you should have the option to send me a private message.  I can send you an addin that I have working so you can look at it.

BTW - what version of ArcGIS are you using?

CoyPotts1
Occasional Contributor III

I followed you.  You can send whenever is convenient for you. 

All of the tests that I have been doing have been in 10.2.2.  I am, however, upgrading to 10.3.1 as we speak, though.  We downgraded to 10.2.2 due to compatibility issues whenever we purchased a secondary software extension from a third party to help us document our strand level (fiber optic cable) detail.  They have since increased compatibility to 10.3 versions, so I am moving back up.

I'll give the Add-In another go as soon as the installs are completed and I'll report my findings at that time. 

0 Kudos
JohnWilmarth
New Contributor II

Hi Coy,

I was researching adding some python to a button and found your post.  We are doing some work with fiber and I would like to know how you like your third party software?  If you like it, please let me know who makes it.

Thanks,

John Wilmarth

Coppell, TX

0 Kudos
CoyPotts1
Occasional Contributor III

I tried the same add-in that I was using before and I got the same results.  I created a new project > toolbar > button, added a message box to the button, and I still get a button that says missing on the new toolbar. 

0 Kudos
CoyPotts1
Occasional Contributor III

Rebecca,

One last question regarding this stuff here.  You reference using a widget to edit your XML files in your comment above, but I don't think you mentioned what the widget is called.  I google search returned a lot of options for XML editors, but I like the way yours looks in the attached image above so I wanted to give that a try and see if I like it.

Thanks!

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

Hi Coy, sorry, was tied up today on my own Python stuff.

I think what I meant was​ that it is easier to let the wizard create the extra buttons, so I create a few extra to stub them out....then I modify them after. I typically use either notepad++, Brackets, or WingPro for all my programming IDE needs.  I think I used the beautify addin in Brackets to format the xml.

Brackets - A modern, open source code editor that understands web design.

i use that for JavaScript too, although I know many like Sublime Text.

THe reason I say it's best to use the wizard is the various id tags that need to match.  To me, it's easier to ignore or delete extra buttons I don't need the  it is to try to add another manually.  That's just my workflow.

btw, I'm running into the issue today that not only do 10.3 addins not work in 10.2, I've had issues with my 10.3 toolboxes not showing up in 10.2.....I need to roll my addin back.  That's just a FYI in case you are dealing with that.

0 Kudos
CoyPotts1
Occasional Contributor III

Yeah, there were quite a few models that we used in 10.3, that we could no longer see when re backed up to 10.2.  Research resulted in me finding out that there is no way to down-save an individual model, but rather you have to down-save the entire toolbox.  I'm sure there are little intricacies that go along with that as well.  I've been simply exporting the models to python and then trying to clean them up as they're not quite perfect once exported.

In reference to creating new buttons manually...I don't even attempt to mess with that lol.  Whenever I add new things, I just add an *_1 at the end of my *_addin.py file and then re-save the project with my newly added features.  NOTE:  I realize that if you save the project, it will automatically add *_1/2/3/4 to the end your existing *_addin.py file, but I actually experienced a complete project folder reset one time when I tried that.  I ended up losing the *_addin.py file that had my tool references and everything, so I was a little agitated

How do you roll an add-in back?  I don't see how to do so.  Is this where the target version in the XML file is used?  If so, mine creates it with a target version of 10.1 every time, so I should be good if that is the case.  

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

I think rolling it back for me will be at least a two prong approach.  the target in the .xml and the rolling back of the toolbox and scripts. hopefully that can be done without too much heartache.

a suggestion for rolling back you models....can you create a new toolbox and isolate what you need and then just save as those?

0 Kudos
CoyPotts1
Occasional Contributor III

Just to highlight on what you referenced above, we did actually experience an issue with the add-in with the users that were still using 10.2.  The add-in was working just fine on my machine, but whenever the others opened their maps, the buttons didn't react when clicked.  Simply saving the toolbox to the 10.1/10.2 version did the trick with no other modification needed.

Thanks again for all of your help!  I'd probably still be lost in documentation somewhere trying to figure it all out

CoyPotts1
Occasional Contributor III

I'm replying to the original post as I am referencing multiple suggestions here.

Ian Broad

Doing what you suggested above did indeed allow me to pull "python" and "import" through the command window, but it didn't fix the issue I am having with the add-in.

I restarted my machine, re-created/re-installed an add-in with one toolbar that had one button, added a MessageBox command to the onClick function...and I still get a button that says missing whenever I open up ArcMap.

Rebecca Strauch

I was looking at my XML config file, and I noticed that my target version was set to 10.1.  Whenever I was working in the 10.2.2 yesterday, my target version was 10.2, but now that I'm in 10.3.1, my target version says 10.1.  Very confusing.  I changed the 10.1 to 10.3.1, and in doing so, the add-in will not show up in ArcMap when I open the document.  It says it installed correctly, but it just doesn't show up.  I changed it back to 10.1 and it shows up again with a missing button.

Is there some sort of issue with that version number that could be causing problems?

0 Kudos