0

I've posted this question on GeoNet 4 days ago. At the moment I've received no answers and no comments so I thought I'd try here as well.

https://geonet.esri.com/activity#nPLoc=/inbox

I have a tool that works fine from My Tooboxes but we would prefer to run it as an addin button. I found GPToolDialog from the pythonaddins module would do the trick.

I set up the button OK and it runs fine when testing OnClick only using a straight forward script like zooming to selected and no pythonaddins methods.

When I tested the same button’s OnClick only using a one line pythonaddins function it wouldn’t work. Even pythonaddins.MessageBox wouldn’t work.

I thought I’d try running the code in the ArcMap Command Line window and it works fine from there.

My button script

import arcpy
import pythonaddins

class ButtonClass1(object):

    """Implementation for Addin_Test_addin.button (Button)"""
    def __init__(self):
        self.enabled = True
        self.checked = False
    def onClick(self):
        pythonaddins.GPToolDialog(r'C:\Users\stazicd\AppData\Roaming\ESRI\Desktop10.1\ArcToolbox\My Toolboxes\PVP Zoom.tbx','PVPZoom')

Would any one know why it isn't working?

2
  • 1
    Welcome to GIS SE! As a new user be sure to take the Tour, if you have not already. Would you be able to edit your question to include a link to your GeoNet thread, please? That way any potential answerers can check to see if there has been a recent answer before investing the time they volunteer here on a question that has been answered elsewhere.
    – PolyGeo
    May 14, 2015 at 7:11
  • posted comment on geonet
    – Hornbydd
    May 14, 2015 at 10:52

1 Answer 1

1

As you can run your code (open a custom GP Tool) from within python window, then you toolbox path and its tool are ok.

It can be a problem with your config.xml. Check this file and look for the button and make sure the Class and id of the button are set to ButtonClass1. e.g:

<Button caption="GPToolDialog" category="Test Python Addin" class="ButtonClass1" id="LibraryName.ButtonClass1" image="" message="" tip="GP Tool Dialog"><Help heading="" /></Button>
1
  • Thanks Farid. Yep, my button ID is fine but that one was certainly worth checking.
    – Don Stazic
    May 15, 2015 at 5:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.