HowTo:  Enable the color highlighting for PYT files in IDLE

相关信息
Article ID: 40256
Software:
ArcGIS for Desktop Advanced 10.1
ArcGIS for Desktop Standard 10.1
ArcGIS for Desktop Basic 10.1
Platforms: N/A

问题描述
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.
已邀请:

EsriSupport

赞同来自:

解决方案
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. 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: 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.


创建及修改时间
Created: 5/14/2012

Last Modified: 7/10/2013
原文链接
http://support.esri.com/en/kno ... 40256

要回复问题请先登录注册