Select to view content in your preferred language

IDLE, *.pyt files, colour highlighting and 64bit

1349
3
10-11-2011 03:42 AM
GraemeBrowning1
Emerging Contributor
I just created my first Python toolbox and when I right-clicked to Edit it the editor defaulted to Notepad.  I much prefer IDLE and so went to Geoprocessing Options to set the Editor as C:\Python27\ArcGIS10.1\Lib\idlelib\idle.pyw.  This enabled Edit to open IDLE but with none of the nice colour highlighting on the text which I assume is because of the *.pyt rather than *.py extension. 

Is there an easy way to have IDLE do colour highlighting on a *.pyt file?

Also, when setting the Editor I could have chosen C:\Python27\ArcGISx6410.1\lib\idlelib\idle.pyw instead of C:\Python27\ArcGIS10.1\Lib\idlelib\idle.pyw - does it matter which I choose? 

I'm assuming that Desktop put C:\Python27\ArcGIS10.1\Lib\idlelib\idle.pyw there and uses it while Server installed and uses C:\Python27\ArcGISx6410.1\lib\idlelib\idle.pyw .
Tags (2)
0 Kudos
3 Replies
ChrisFox3
Frequent Contributor
Hi Graeme,

You need to edit the source code for IDLE to accomplish this. Go to your idelib folder for the install of IDLE and edit the EditorWindow.py file (you may want to make a copy just in case there is a problem). Go to the following 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


Add ".pyt" to the list of extension to check and save the changes. This should now highlight the syntax when you open it in IDLE.
0 Kudos
KevinBell
Deactivated User
thanks!  that works just fine!
0 Kudos
DavidAllen
Frequent Contributor
Can the same be set up for PythonWin?
0 Kudos