Copyright Anne Dawson 2005 - 2014

This file is: http://www.annedawson.net/Python_Editor_IDLE.htm
First created: Tuesday 8th March 2005, 7:28 PT, AD
Last updated: Sunday 17th November 2013, 12:48 PT, AD

IDLE Editor for Python

by Anne Dawson PhD

This page explains how to run the IDLE integrated development environment (IDE) for editing and running Python 2.x or Python 3 programs. The IDLE GUI (graphical user interface) is automatically installed with the Python interpreter. IDLE was designed specifically for use with Python. IDLE has a number of features to help you develop your Python programs including powerful syntax highlighting.

Watch the IDLE Editor movie below (11 minutes)...

Python Editor IDLE movie

Notice that with syntax highlighting, Python keywords, comments, literal text etc are displayed in different colours or fonts, which makes it much easier for programmers to find errors in their program code. Not only can you edit Python programs using IDLE, but you can also execute (run) them from within IDLE.

Which version of Python should you install?
Go to Python 2 / IDLE installation instructions (in case Python/IDLE is not already installed)
Go to Python 3 / IDLE installation instructions (in case Python/IDLE is not already installed)
Example Python 2.x Programs (HTML format)
Example Python Programs (text format)
Example Python 3.x Programs (text format)

More Python Resources




Follow these instructions to write and run a simple Python program using the IDLE editor:

Python Startup Sreen




1.  Start IDLE (see screen above). You will then see a window entitled "Python Shell" ...


Python Shell Screen




2.  From the Python Shell window, select New Window from the File menu.

3.  You will see a window entitled "Untitled"



Python Untitled Screen



4.  From the File menu, select Save As, 
     and select a folder to save your Python program file.

Python IDLE Save As Screen



5.  Select a folder to save your file in.

6.  In the File name: text box, type: program1.py

7.  Then click on the Save button. 
     You will then see a blank editor window ready 
     for you to type in your Python program.




Python IDLE Editor Window





8.  The following program statement will run under Python 2.x or Python 3.0 

    Type in the following text into this window 
    (make sure the word print is all in lower case):

     print ("Hello World")

     If you're running Python 2.x, the text will automatically change colour to look like this:

     print("Hello World")

     If you're running Python 3.0.x, the text will automatically change colour to look like this:

     print("Hello World")




9.  To run this program, select Run Module from the Run menu.


     You should see a reminder to save the Source (your program). 
     Click on OK to save.

     Then you will see your program running in a Python Shell window.

Pogram running in Python 3 Shell




10.  Close all Python windows to quit Python.






IMPORTANT: 



To open your Python file again, 
locate the file in the folder, 
click once on the file name it to highlight it, 
then right-click on the mouse to see the options shown in
the screen below, and select Edit with IDLE 
to open the editor window. 


Edit with IDLE screen



From the editor window (the window with the program's name in the title bar),
select Run Module from the Run menu to 
see the program run in the Python Shell window.



****************************************************************
    To close a Python Shell or IDLE editor window
     Select Close from the File menu. 
****************************************************************
    To open and run an existing program file
     Select Open from the File menu.
****************************************************************
    Getting Help on IDLE
     Select IDLE Help from the Help menu
****************************************************************
    Getting Help on Python
     You select Python Docs from the Help menu or press keyboard key F1.
     The path for Python 3.0 is not correct - IDLE currently searches for documents here:
     http://docs.python.org/dev/3.0/ 
     when the Python 3 documentation is actually located here: http://docs.python.org/3.0/

Documentation for all versions of Python can be found here: http://docs.python.org
**************************************************************** To exit the Python Shell or IDLE editor Select Exit from the File menu. ****************************************************************

Example Python 2.x Programs (HTML format) Example Python 2.x Programs (text format) Example Python 3.0 Programs (text format)

 


Search for more computer science topics on www.annedawson.net

www.annedawson.net

Valid XHTML 1.0!

Valid CSS!