- -
-

24.6. IDLE

-

IDLE is Python’s Integrated Development and Learning Environment.

+
+

IDLE — Python editor and shell

+

Source code: Lib/idlelib/

+
+

IDLE is Python’s Integrated Development and Learning Environment.

IDLE has the following features:

    -
  • coded in 100% pure Python, using the tkinter GUI toolkit
  • -
  • cross-platform: works mostly the same on Windows, Unix, and Mac OS X
  • -
  • Python shell window (interactive interpreter) with colorizing -of code input, output, and error messages
  • -
  • multi-window text editor with multiple undo, Python colorizing, -smart indent, call tips, auto completion, and other features
  • -
  • search within any window, replace within editor windows, and search -through multiple files (grep)
  • -
  • debugger with persistent breakpoints, stepping, and viewing -of global and local namespaces
  • -
  • configuration, browsers, and other dialogs
  • +
  • cross-platform: works mostly the same on Windows, Unix, and macOS

  • +
  • Python shell window (interactive interpreter) with colorizing +of code input, output, and error messages

  • +
  • multi-window text editor with multiple undo, Python colorizing, +smart indent, call tips, auto completion, and other features

  • +
  • search within any window, replace within editor windows, and search +through multiple files (grep)

  • +
  • debugger with persistent breakpoints, stepping, and viewing +of global and local namespaces

  • +
  • configuration, browsers, and other dialogs

- -
-

24.6.1.3. Format menu (Editor window only)

-
-
Indent Region
-
Shift selected lines right by the indent width (default 4 spaces).
-
Dedent Region
-
Shift selected lines left by the indent width (default 4 spaces).
-
Comment Out Region
-
Insert ## in front of selected lines.
-
Uncomment Region
-
Remove leading # or ## from selected lines.
-
Tabify Region
-
Turn leading stretches of spaces into tabs. (Note: We recommend using -4 space blocks to indent Python code.)
-
Untabify Region
-
Turn all tabs into the correct number of spaces.
-
Toggle Tabs
-
Open a dialog to switch between indenting with spaces and tabs.
-
New Indent Width
-
Open a dialog to change indent width. The accepted default by the Python -community is 4 spaces.
-
Format Paragraph
-
Reformat the current blank-line-delimited paragraph in comment block or +
+
+

Format menu (Editor window only)

+
+
Format Paragraph

Reformat the current blank-line-delimited paragraph in comment block or multiline string or selected line in a string. All lines in the -paragraph will be formatted to less than N columns, where N defaults to 72.

-
Strip trailing whitespace
-
Remove any space characters after the last non-space character of a line.
+paragraph will be formatted to less than N columns, where N defaults to 72.

+ +
Indent Region

Shift selected lines right by the indent width (default 4 spaces).

+
+
Dedent Region

Shift selected lines left by the indent width (default 4 spaces).

+
+
Comment Out Region

Insert ## in front of selected lines.

+
+
Uncomment Region

Remove leading # or ## from selected lines.

+
+
Tabify Region

Turn leading stretches of spaces into tabs. (Note: We recommend using +4 space blocks to indent Python code.)

+
+
Untabify Region

Turn all tabs into the correct number of spaces.

+
+
Toggle Tabs

Open a dialog to switch between indenting with spaces and tabs.

+
+
New Indent Width

Open a dialog to change indent width. The accepted default by the Python +community is 4 spaces.

+
+
Strip Trailing Chitespace

Remove trailing space and other whitespace characters after the last +non-whitespace character of a line by applying str.rstrip to each line, +including lines within multiline strings. Except for Shell windows, +remove extra newlines at the end of the file.

+
-
-
-

24.6.1.4. Run menu (Editor window only)

-
-
Python Shell
-
Open or wake up the Python Shell window.
-
Check Module
-
Check the syntax of the module currently open in the Editor window. If the -module has not been saved IDLE will either prompt the user to save or -autosave, as selected in the General tab of the Idle Settings dialog. If -there is a syntax error, the approximate location is indicated in the -Editor window.
-
Run Module
-
Do Check Module (above). If no error, restart the shell to clean the + +
+

Run menu (Editor window only)

+
+
Run Module

Do Check Module. If no error, restart the shell to clean the environment, then execute the module. Output is displayed in the Shell -window. Note that output requires use of print or write. +window. Note that output requires use of print or write. When execution is complete, the Shell retains focus and displays a prompt. At this point, one may interactively explore the result of execution. -This is similar to executing a file with python -i file at a command -line.

+This is similar to executing a file with python -i file at a command +line.

+
-
-
-

24.6.1.5. Shell menu (Shell window only)

-
-
View Last Restart
-
Scroll the shell window to the last Shell restart.
-
Restart Shell
-
Restart the shell to clean the environment.
-
Interrupt Execution
-
Stop a running program.
+
+
Run… Customized

Same as Run Module, but run the module with customized +settings. Command Line Arguments extend sys.argv as if passed +on a command line. The module can be run in the Shell without restarting.

+
-
-
-

24.6.1.6. Debug menu (Shell window only)

-
-
Go to File/Line
-
Look on the current line. with the cursor, and the line above for a filename +
+
Check Module

Check the syntax of the module currently open in the Editor window. If the +module has not been saved IDLE will either prompt the user to save or +autosave, as selected in the General tab of the Idle Settings dialog. If +there is a syntax error, the approximate location is indicated in the +Editor window.

+
+
+
+
Python Shell

Open or wake up the Python Shell window.

+
+
+ +
+

Shell menu (Shell window only)

+
+
View Last Restart

Scroll the shell window to the last Shell restart.

+
+
Restart Shell

Restart the shell to clean the environment and reset display and exception handling.

+
+
Previous History

Cycle through earlier commands in history which match the current entry.

+
+
Next History

Cycle through later commands in history which match the current entry.

+
+
Interrupt Execution

Stop a running program.

+
+
+
+
+

Debug menu (Shell window only)

+
+
Go to File/Line

Look on the current line. with the cursor, and the line above for a filename and line number. If found, open the file if not already open, and show the line. Use this to view source lines referenced in an exception traceback and lines found by Find in Files. Also available in the context menu of -the Shell window and Output windows.

+the Shell window and Output windows.

+
-
-
Debugger (toggle)
-
When actived, code entered in the Shell or run from an Editor will run +
+
Debugger (toggle)

When activated, code entered in the Shell or run from an Editor will run under the debugger. In the Editor, breakpoints can be set with the context -menu. This feature is still incomplete and somewhat experimental.

-
Stack Viewer
-
Show the stack traceback of the last exception in a tree widget, with -access to locals and globals.
-
Auto-open Stack Viewer
-
Toggle automatically opening the stack viewer on an unhandled exception.
+menu. This feature is still incomplete and somewhat experimental.

+
+
Stack Viewer

Show the stack traceback of the last exception in a tree widget, with +access to locals and globals.

+
+
Auto-open Stack Viewer

Toggle automatically opening the stack viewer on an unhandled exception.

+
-
-
-

24.6.1.7. Options menu (Shell and Editor)

-
-
Configure IDLE
-

Open a configuration dialog and change preferences for the following: + +

+

Options menu (Shell and Editor)

+
+
Configure IDLE

Open a configuration dialog and change preferences for the following: fonts, indentation, keybindings, text color themes, startup windows and -size, additional help sources, and extensions (see below). On OS X, -open the configuration dialog by selecting Preferences in the application -menu. To use a new built-in color theme (IDLE Dark) with older IDLEs, -save it as a new custom theme.

-

Non-default user settings are saved in a .idlerc directory in the user’s -home directory. Problems caused by bad user configuration files are solved -by editing or deleting one or more of the files in .idlerc.

+size, additional help sources, and extensions. On macOS, open the +configuration dialog by selecting Preferences in the application +menu. For more details, see +Setting preferences under Help and preferences.

-
Code Context (toggle)(Editor Window only)
-
Open a pane at the top of the edit window which shows the block context -of the code which has scrolled above the top of the window.
-
-
-

24.6.1.8. Window menu (Shell and Editor)

-
-
Zoom Height
-
Toggles the window between normal size and maximum height. The initial size +

Most configuration options apply to all windows or all future windows. +The option items below only apply to the active window.

+
+
Show/Hide Code Context (Editor Window only)

Open a pane at the top of the edit window which shows the block context +of the code which has scrolled above the top of the window. See +Code Context in the Editing and Navigation section +below.

+
+
Show/Hide Line Numbers (Editor Window only)

Open a column to the left of the edit window which shows the number +of each line of text. The default is off, which may be changed in the +preferences (see Setting preferences).

+
+
Zoom/Restore Height

Toggles the window between normal size and maximum height. The initial size defaults to 40 lines by 80 chars unless changed on the General tab of the -Configure IDLE dialog.

+Configure IDLE dialog. The maximum height for a screen is determined by +momentarily maximizing a window the first time one is zoomed on the screen. +Changing screen settings may invalidate the saved height. This toggle has +no effect when a window is maximized.

+
-

The rest of this menu lists the names of all open windows; select one to bring -it to the foreground (deiconifying it if necessary).

-
-
-

24.6.1.9. Help menu (Shell and Editor)

-
-
About IDLE
-
Display version, copyright, license, credits, and more.
-
IDLE Help
-
Display a help file for IDLE detailing the menu options, basic editing and -navigation, and other tips.
-
Python Docs
-
Access local Python documentation, if installed, or start a web browser -and open docs.python.org showing the latest Python documentation.
-
Turtle Demo
-
Run the turtledemo module with example python code and turtle drawings.
+ +
+

Window menu (Shell and Editor)

+

Lists the names of all open windows; select one to bring it to the foreground +(deiconifying it if necessary).

+
+
+

Help menu (Shell and Editor)

+
+
About IDLE

Display version, copyright, license, credits, and more.

+
+
IDLE Help

Display this IDLE document, detailing the menu options, basic editing and +navigation, and other tips.

+
+
Python Docs

Access local Python documentation, if installed, or start a web browser +and open docs.python.org showing the latest Python documentation.

+
+
Turtle Demo

Run the turtledemo module with example Python code and turtle drawings.

+

Additional help sources may be added here with the Configure IDLE dialog under -the General tab.

-
-
-

24.6.1.10. Context Menus

-

Open a context menu by right-clicking in a window (Control-click on OS X). +the General tab. See the Help sources subsection below +for more on Help menu choices.

+ +
+

Context menus

+

Open a context menu by right-clicking in a window (Control-click on macOS). Context menus have the standard clipboard functions also on the Edit menu.

-
-
Cut
-
Copy selection into the system-wide clipboard; then delete the selection.
-
Copy
-
Copy selection into the system-wide clipboard.
-
Paste
-
Insert contents of the system-wide clipboard into the current window.
+
+
Cut

Copy selection into the system-wide clipboard; then delete the selection.

+
+
Copy

Copy selection into the system-wide clipboard.

+
+
Paste

Insert contents of the system-wide clipboard into the current window.

+

Editor windows also have breakpoint functions. Lines with a breakpoint set are specially marked. Breakpoints only have an effect when running under the -debugger. Breakpoints for a file are saved in the user’s .idlerc directory.

-
-
Set Breakpoint
-
Set a breakpoint on the current line.
-
Clear Breakpoint
-
Clear the breakpoint on that line.
+debugger. Breakpoints for a file are saved in the user’s .idlerc +directory.

+
+
Set Breakpoint

Set a breakpoint on the current line.

+
+
Clear Breakpoint

Clear the breakpoint on that line.

+
-

Shell and Output windows have the following.

-
-
Go to file/line
-
Same as in Debug menu.
+

Shell and Output windows also have the following.

+
+
Go to file/line

Same as in Debug menu.

+
-
-