I created a addin from python addin wizard with many menus and buttons. For one of these buttons I want to open a Python (.py) script from my Toolbox. I tried many ways but no one works. I want this because this script open the parameter dialog box with some parameters to input. I really need to open the windows to put the parameters.

class ConfereChave(object):
    """Implementation for ConfereChave.button (Button)"""
    def __init__(self):
        self.enabled = True
        self.checked = False
    def onClick(self):
        pythonaddins.MessageBox('Text', 'Confere Chave', 0)
        relPath = os.path.dirname(r'F:')
        TBX = relPath + r"\Agro\Agro.tbx"
        pythonaddins.GPToolDialog(r'F:\Agro\Agro.tbx', 'ConfereChave')

I get this error:

Executing: ConfereChave F:\AgroBD.gdb\IBGE\Brasil_Municipios Alfabetico 
COD_IBGE teste1 Float
Start Time: Fri Jul 21 00:31:52 2017
ERROR 000576: Script associated with this tool does not exist.
Failed to execute (ConfereChave).
Failed at Fri Jul 21 00:31:53 2017 (Elapsed Time: 0,69 seconds)

I already put the relative path but do not work too.

Code updated but do not work, the same error remains.Remember CampoConfere is a python script (py)


I suspect that this is because installing a Python AddIn copies folders to locations well known to ArcMap/ArcPy without updating all paths within the scripts copied.

I do something similar to what you are wanting to do in one of my applications and I have code like that below in my test_addin.py which looks like it is designed to find the tool at its new location:

import os
relPath = os.path.dirname(__file__)
PythonTBX = relPath + r"\test.pyt"
pythonaddins.GPToolDialog(PythonTBX, 'TestTool')

Note that I am using a Python Toolbox (*.pyt) tool whereas you are using a Standard Toolbox (*.tbx) with a Python script tool but I think the same coding pattern should work.

  • Yes, you can use it with a script tool, too – Andreas Müller Jul 21 '17 at 10:48
  • PolyGeo, I updated the code, but not work...I got the same error when I run the script. The path is updated. I also updated the code in this question. – vcruvinelr Jul 21 '17 at 17:34
  • Andreas, it's not working with a python script...even putting the relative path – vcruvinelr Jul 21 '17 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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