0

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)

asked Jul 21, 2017 at 3:37

1 Answer 1

1

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.

answered Jul 21, 2017 at 5:10
3
  • Yes, you can use it with a script tool, too Commented Jul 21, 2017 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. Commented Jul 21, 2017 at 17:34
  • Andreas, it's not working with a python script...even putting the relative path Commented Jul 21, 2017 at 17:35

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.