Last updated: Saturday 7th December 2024, 9:34 PT



Home

IDLE Editor for Python

by Dr Anne Dawson

This page explains how to run 
the IDLE integrated development environment
(IDE) for editing and running 
Python 2 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.  



Python with IDLE installation video (11 min)

Python Editor IDLE video (11 min)

Python programming videos



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

Go to Python 3 / IDLE installation instructions

Wiki page on IDLE

Example Python 3.x Programs (HTML format)

Example Python 3.x Programs (text format)

Example Python 2.x Programs (HTML format)

Example Python Programs (text format)

More Python Resources



1.  Start IDLE. 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.x 

    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.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.

Program 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





To associate Python files with IDLE: 



****************************************************************
 
  To run a Python program:

     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:
     https://docs.python.org/dev/3.0/ 
     when the Python 3 documentation 
     is actually located here: 
     https://docs.python.org/3.0/
     
Documentation for all versions of Python can be found here: https://docs.python.org
**************************************************************** To exit the Python Shell or IDLE editor: Select Exit from the File menu. ****************************************************************

Example Python 3.x Programs (HTML format)

Example Python 3.x Programs (text format)

Example Python 2.x Programs (HTML format)

Example Python 2.x Programs (text format)




Home