HOW TO

Enable the color highlighting for PYT files in IDLE

Last Published: April 25, 2020

Summary

Instructions provided describe how to enable color highlighting of Python toolboxes (PYT files) in the IDLE IDE.

Python toolboxes (.pyt) are geoprocessing toolboxes that are created entirely in Python. Although these tools are recognized by ArcGIS software as Python scripts, they may or may not be treated as Python scripts within various Python IDEs. To ensure that these files are recognized by a Python IDE it may be necessary to include the .pyt extension in the settings for the Python IDE.

Procedure

The following steps enable color highlighting on a Python toolbox that is being edited within IDLE.

  1. Open Windows Explorer and navigate to the idlelib folder for the install of IDLE. By default this location should be similar to C:\Python27\ArcGIS10.1\Lib\idlelib.
  2. Open the EditorWindow.py file for editing in a Python IDE or Notepad.
  3. Locate the following lines of code within the EditorWindow.py file.
    Code:
    def ispythonsource(self, filename):
    if not filename or os.path.isdir(filename):
    return True
    base, ext = os.path.splitext(os.path.basename(filename))
    if os.path.normcase(ext) in (".py", ".pyw")
    return True

  4. Add ".pyt" to the list of extensions. The updated EditorWindow.py file should look similar to:
    Code:
    def ispythonsource(self, filename):
    if not filename or os.path.isdir(filename):
    return True
    base, ext = os.path.splitext(os.path.basename(filename))
    if os.path.normcase(ext) in (".py", ".pyw", ".pyt")
    return True

  5. Save the changes to the EditorWindow.py file.

Article ID:000011556

Software:
  • ArcMap

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic