0

I need to open a Python Script using GPToolDialog(), but the script is in a Toolset, not in the Toolbox main path.

I tried many ways to solve but do not work, examples:

Example 1:

pythonaddins.GPToolDialog(r'Path to Toolbox\Toolset', 'Script')

Example 2:

pythonaddins.GPToolDialog(r'Path to Toolbox', 'Toolset\Script')

No one ot the examples works.

2

If you would try to run this code outside of ArcGIS Desktop application (e.g., in a Python shell), you'd get the following error:

pythonaddins.GPToolDialog(r'C:\GIS\Temp\ArcGISHomeFolder\Toolbox.tbx', 'AddFields')
Traceback (most recent call last):
  Python Shell, prompt 2, line 1
RuntimeError: Not running in a desktop application.

You need to run this code in ArcGIS Desktop (for instance, ArcMap or ArcCatalog). In other words, you cannot make your arbitrary Python script running outside of ArcGIS Desktop application open up a GP tool dialog. The logic for this would work only when the Python code is executed either within the Python add-in in ArcGIS Desktop application or when you run this code in a Python script that is a script tool or within the Python window:

import pythonaddins
pythonaddins.GPToolDialog(r'C:\GIS\Temp\ArcGISHomeFolder\Toolbox.tbx', 'AddFields')

This will open up the tool dialog window. Keep in mind that you need to specify the tool Name, not its Label.

Help page for GPToolDialog.

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.