The script tool framework and the Python toolbox are different options for creating Python-based geoprocessing tools in
In the script tool framework, you do the following:
- Define parameters using the wizard.
- Create validation code in the toolbox.
- Create source code.
A second approach for creating Python-based tools is the Python toolbox. In a Python toolbox, parameter definitions, validation code, and the source code are all handled with Python code.
For those with Python experience, Python toolboxes provide the opportunity to use your Python skills and create tools directly from Python. If you are new to Python, it may be better to create tools in custom toolboxes where you use the New Script dialog box to proceed through the necessary parts of a script tool.
If you use or are planning to use significant validation code in a script tool, the experience is more straightforward in a Python toolbox.
Organization
Script tools and Python toolboxes are organized as described below.
Custom toolbox | Python toolbox |
---|---|
Script tools in a custom toolbox are organized into the following parts:
| A Python toolbox is a Python script with a .pyt extension that contains all aspects of a toolbox and its tools: parameters, validation, and source code. This is done using Python classes: one class for the toolbox and one class for each of the tools. |
Editing
Script tools and Python toolboxes can be edited as described below.
Custom toolbox | Python toolbox |
---|---|
The source code can be edited in any editor. The parameters are edited through the script tool wizard. Validation code (if used) can be edited from the Validation tab on the script tool's dialog box or in a separate Python integrated development environment (IDE). | Python toolbox files can be edited in any editor, and all parts of the tool (parameter definitions, validation code, and source code) can be edited in the same place. Python toolboxes can only be edited in an editor; they do not support copying and pasting within a toolbox or between toolboxes. |
Additional tools
The inclusion of other tools in a toolbox is described below.
Custom toolbox | Python toolbox |
---|---|
Custom toolboxes support various tool types, including Python script tools and model tools (built with ModelBuilder). | Python toolboxes do not directly support other tool types; you cannot add model or built-in tools to your Python toolbox. However, you can call tools in other toolboxes from within the Python toolbox code. |
Additional security
Security for script tools and Python toolboxes is described below.
Custom toolbox | Python toolbox |
---|---|
For script tools in a custom toolbox, you can embed their source code in the toolbox and secure it with a password. | You can encrypt a Python toolbox .pyt file in place and secure it with a password. |