IDLE¶
+IDLE¶
Source code: Lib/idlelib/
IDLE is Python’s Integrated Development and Learning Environment.
@@ -119,8 +218,8 @@Navigation
of global and local namespacesconfiguration, browsers, and other dialogs
Menus¶
+Menus¶
IDLE has two main window types, the Shell window and the Editor window. It is possible to have multiple editor windows simultaneously. On Windows and Linux, each has its own top menu. Each menu documented below indicates @@ -131,8 +230,8 @@
Menus
On macOS, there is one application menu. It dynamically changes according
to the window currently selected. It has an IDLE menu, and some entries
described below are moved around to conform to Apple guidelines.
-
-File menu (Shell and Editor)¶
+
+File menu (Shell and Editor)¶
- New File
Create a new file editing window.
@@ -170,9 +269,9 @@ File menu (Shell and Editor)
-Edit menu (Shell and Editor)¶
+
+
+Edit menu (Shell and Editor)¶
- Undo
Undo the last change to the current window. A maximum of 1000 changes may
be undone.
@@ -217,9 +316,9 @@ Edit menu (Shell and Editor)
-Format menu (Editor window only)¶
+
+
+Format menu (Editor window only)¶
- Indent Region
Shift selected lines right by the indent width (default 4 spaces).
@@ -249,9 +348,9 @@ Edit menu (Shell and Editor)
-Run menu (Editor window only)¶
+
+
+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
@@ -280,9 +379,9 @@
Edit menu (Shell and Editor)
-Shell menu (Shell window only)¶
+
+
+Shell menu (Shell window only)¶
- View Last Restart
Scroll the shell window to the last Shell restart.
@@ -295,9 +394,9 @@ Shell menu (Shell window only)
-Debug menu (Shell window only)¶
+
+
+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
@@ -317,9 +416,9 @@
Debug menu (Shell window only)
-Options menu (Shell and Editor)¶
+
+
+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
@@ -349,14 +448,14 @@
Options menu (Shell and Editor)
-Window menu (Shell and Editor)¶
+
+
+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)¶
+
+
+Help menu (Shell and Editor)¶
- About IDLE
Display version, copyright, license, credits, and more.
@@ -372,9 +471,9 @@ Help menu (Shell and Editor)Help sources subsection below
for more on Help menu choices.
-
-
-Context Menus¶
+
+
+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.
@@ -407,12 +506,12 @@ Help menu (Shell and Editor)
-Editing and navigation¶
-
-Editor windows¶
+
+
+
+Editing and Navigation¶
+
+Editor windows¶
IDLE may open editor windows when it starts, depending on settings
and how you start IDLE. Thereafter, use the File menu. There can be only
one open editor window for a given file.
@@ -422,41 +521,41 @@ Editor windows
-Key bindings¶
+
+
+Key bindings¶
In this section, ‘C’ refers to the Control key on Windows and Unix and
the Command key on macOS.
Backspace deletes to the left; Del deletes to the right
-C-Backspace delete word left; C-Del delete word to the right
-Arrow keys and Page Up/Page Down to move around
-C-LeftArrow and C-RightArrow moves by words
+C-Backspace delete word left; C-Del delete word to the right
+Arrow keys and Page Up/Page Down to move around
+C-LeftArrow and C-RightArrow moves by words
Home/End go to begin/end of line
-C-Home/C-End go to begin/end of file
+C-Home/C-End go to begin/end of file
Some useful Emacs bindings are inherited from Tcl/Tk:
-C-a beginning of line
-C-e end of line
-C-k kill line (but doesn’t put it in clipboard)
-C-l center window around the insertion point
-C-b go backward one character without deleting (usually you can
+
C-a beginning of line
+C-e end of line
+C-k kill line (but doesn’t put it in clipboard)
+C-l center window around the insertion point
+C-b go backward one character without deleting (usually you can
also use the cursor key for this)
-C-f go forward one character without deleting (usually you can
+
C-f go forward one character without deleting (usually you can
also use the cursor key for this)
-C-p go up one line (usually you can also use the cursor key for
+
C-p go up one line (usually you can also use the cursor key for
this)
-C-d delete next character
+C-d delete next character
-Standard keybindings (like C-c to copy and C-v to paste)
+
Standard keybindings (like C-c to copy and C-v to paste)
may work. Keybindings are selected in the Configure IDLE dialog.
-
-
-Automatic indentation¶
+
+
+Automatic indentation¶
After a block-opening statement, the next line is indented by 4 spaces (in the
Python Shell window by one tab). After certain keywords (break, return etc.)
the next line is dedented. In leading indentation, Backspace deletes up
@@ -465,9 +564,9 @@
Automatic indentation
See also the indent/dedent region commands on the
Format menu.
-
-
-Completions¶
+
+
+Completions¶
Completions are supplied, when requested and available, for module
names, attributes of classes or functions, or filenames. Each request
method displays a completion box with existing names. (See tab
@@ -489,7 +588,7 @@
Automatic indentation
Instead of waiting, or after a box is closed, open a completion box
immediately with Show Completions on the Edit menu. The default hot
-key is C-space. If one types a prefix for the desired name
+key is C-space. If one types a prefix for the desired name
before opening the box, the first match or near miss is made visible.
The result is the same as if one enters a prefix
after the box is displayed. Show Completions after a quote completes
@@ -509,9 +608,9 @@
Automatic indentationCompletion boxes initially exclude names beginning with ‘_’ or, for
modules, not included in ‘__all__’. The hidden names can be accessed
by typing ‘_’ after ‘.’, either before or after the box is opened.
-
-
-Calltips¶
+
+
+Calltips¶
A calltip is shown automatically when one types ( after the name
of an accessible function. A function name expression may include
dots and subscripts. A calltip remains until it is clicked, the cursor
@@ -535,9 +634,9 @@
Automatic indentationIn an editor, import statements have no effect until one runs the file.
One might want to run a file after writing import statements, after
adding function definitions, or after opening an existing file.
-
-
-Code Context¶
+
+
+Code Context¶
Within an editor window containing Python code, code context can be toggled
in order to show or hide a pane at the top of the window. When shown, this
pane freezes the opening lines for block code, such as those beginning with
@@ -550,33 +649,44 @@
Automatic indentation
The text and background colors for the context pane can be configured under
the Highlights tab in the Configure IDLE dialog.
-
-
-Python Shell window¶
-With IDLE’s Shell, one enters, edits, and recalls complete statements.
-Most consoles and terminals only work with a single physical line at a time.
+
+
+Shell window¶
+In IDLE’s Shell, enter, edit, and recall complete statements. (Most
+consoles and terminals only work with a single physical line at a time).
+Submit a single-line statement for execution by hitting Return
+with the cursor anywhere on the line. If a line is extended with
+Backslash (\), the cursor must be on the last physical line.
+Submit a multi-line compound statement by entering a blank line after
+the statement.
When one pastes code into Shell, it is not compiled and possibly executed
-until one hits Return. One may edit pasted code first.
-If one pastes more that one statement into Shell, the result will be a
+until one hits Return, as specified above.
+One may edit pasted code first.
+If one pastes more than one statement into Shell, the result will be a
SyntaxError
when multiple statements are compiled as if they were one.
+Lines containing`’RESTART’` mean that the user execution process has been
+re-started. This occurs when the user execution process has crashed,
+when one requests a restart on the Shell menu, or when one runs code
+in an editor window.
The editing features described in previous subsections work when entering
code interactively. IDLE’s Shell window also responds to the following keys.
-C-c interrupts executing command
-C-d sends end-of-file; closes window if typed at a >>>
prompt
-Alt-/ (Expand word) is also useful to reduce typing
+C-c interrupts executing command
+C-d sends end-of-file; closes window if typed at a >>>
prompt
+Alt-/ (Expand word) is also useful to reduce typing
Command history
-Alt-p retrieves previous command matching what you have typed. On
-macOS use C-p.
-Alt-n retrieves next. On macOS use C-n.
-Return while on any previous command retrieves that command
+Alt-p retrieves previous command matching what you have typed. On
+macOS use C-p.
+Alt-n retrieves next. On macOS use C-n.
+Return while the cursor is on any previous command
+retrieves that command
-
-
-Text colors¶
+
+
+Text colors¶
Idle defaults to black on white text, but colors text with special meanings.
For the shell, these are shell output, shell error, user output, and
user error. For Python code, at the shell prompt or in an editor, these are
@@ -592,10 +702,10 @@
Text colors
-Startup and code execution¶
+
+
+
+Startup and Code Execution¶
Upon startup with the -s
option, IDLE will execute the file referenced by
the environment variables IDLESTARTUP
or PYTHONSTARTUP
.
IDLE first checks for IDLESTARTUP
; if IDLESTARTUP
is present the file
@@ -608,8 +718,8 @@
Startup and code execution
-Command line usage¶
+
+Command line usage¶
idle.py [-c command] [-d] [-e] [-h] [-i] [-r file] [-s] [-t title] [-] [arg] ...
-c command run command in the shell window
@@ -632,9 +742,9 @@ Command line usagesys.argv reflects the arguments passed to IDLE itself.
-
-
-Startup failure¶
+
+
+Startup failure¶
IDLE uses a socket to communicate between the IDLE GUI process and the user
code execution process. A connection must be established whenever the Shell
starts or restarts. (The latter is indicated by a divider line that says
@@ -684,9 +794,9 @@
Startup failure
-Running user code¶
+
+
+Running user code¶
With rare exceptions, the result of executing Python code with IDLE is
intended to be the same as executing the same code by the default method,
directly with Python in a text-mode system console or terminal window.
@@ -726,9 +836,9 @@
Running user code
-User output in Shell¶
+
+
+User output in Shell¶
When a program outputs text, the result is determined by the
corresponding output device. When IDLE executes user code, sys.stdout
and sys.stderr
are connected to the display area of IDLE’s Shell. Some of
@@ -780,9 +890,9 @@
User output in ShellSqueezed output is expanded in place by double-clicking the label.
It can also be sent to the clipboard or a separate view window by
right-clicking the label.
-
-
-Developing tkinter applications¶
+
+
+Developing tkinter applications¶
IDLE is intentionally different from standard Python in order to
facilitate development of tkinter programs. Enter import tkinter as tk;
root = tk.Tk()
in standard Python and nothing appears. Enter the same
@@ -800,9 +910,9 @@
Developing tkinter applications
-Running without a subprocess¶
+
+
+Running without a subprocess¶
By default, IDLE executes user code in a separate subprocess via a socket,
which uses the internal loopback interface. This connection is not
externally visible and no data is sent to or received from the internet.
@@ -825,12 +935,12 @@
Running without a subprocess
Deprecated since version 3.4.
-
-
-
-Help and preferences¶
-
-Help sources¶
+
+
+
+Help and Preferences¶
+
+Help sources¶
Help menu entry “IDLE Help” displays a formatted html version of the
IDLE chapter of the Library Reference. The result, in a read-only
tkinter text window, is close to what one sees in a web browser.
@@ -845,9 +955,9 @@
Help and preferences
Selected URLs can be added or removed from the help menu at any time using the
General tab of the Configure IDLE dialog.
-
-
-Setting preferences¶
+
+
+Setting preferences¶
The font preferences, highlighting, keys, and general preferences can be
changed via Configure IDLE on the Option menu.
Non-default user settings are saved in a .idlerc
directory in the user’s
@@ -863,23 +973,23 @@
Help and preferences
-
-
-IDLE on macOS¶
+
+
+IDLE on macOS¶
Under System Preferences: Dock, one can set “Prefer tabs when opening
documents” to “Always”. This setting is not compatible with the tk/tkinter
GUI framework used by IDLE, and it breaks a few IDLE features.
-
-
-Extensions¶
+
+
+Extensions¶
IDLE contains an extension facility. Preferences for extensions can be
changed with the Extensions tab of the preferences dialog. See the
beginning of config-extensions.def in the idlelib directory for further
information. The only current default extension is zzdummy, an example
also used for testing.
-
-
-
+
File menu (Shell and Editor)¶
+File menu (Shell and Editor)¶
- New File
Create a new file editing window.
@@ -170,9 +269,9 @@
File menu (Shell and Editor)
-Edit menu (Shell and Editor)¶
+
Edit menu (Shell and Editor)¶
- Undo
Undo the last change to the current window. A maximum of 1000 changes may be undone.
@@ -217,9 +316,9 @@Edit menu (Shell and Editor) -
Format menu (Editor window only)¶
+
Format menu (Editor window only)¶
- Indent Region
Shift selected lines right by the indent width (default 4 spaces).
@@ -249,9 +348,9 @@
Edit menu (Shell and Editor)
-Run menu (Editor window only)¶
+
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 @@ -280,9 +379,9 @@
Edit menu (Shell and Editor) -
Shell menu (Shell window only)¶
+
Shell menu (Shell window only)¶
- View Last Restart
Scroll the shell window to the last Shell restart.
@@ -295,9 +394,9 @@
Shell menu (Shell window only)
-Debug menu (Shell window only)¶
+
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 @@ -317,9 +416,9 @@
Debug menu (Shell window only) -
Options menu (Shell and Editor)¶
+
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 @@ -349,14 +448,14 @@
Options menu (Shell and Editor) -
Window menu (Shell and Editor)¶
+
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)¶
+ +Help menu (Shell and Editor)¶
- About IDLE
Display version, copyright, license, credits, and more.
@@ -372,9 +471,9 @@
Help menu (Shell and Editor)Help sources subsection below for more on Help menu choices. -
Context Menus¶
+ +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.
-
@@ -407,12 +506,12 @@
Backspace deletes to the left; Del deletes to the right
-C-Backspace delete word left; C-Del delete word to the right
-Arrow keys and Page Up/Page Down to move around
-C-LeftArrow and C-RightArrow moves by words
+C-Backspace delete word left; C-Del delete word to the right
+Arrow keys and Page Up/Page Down to move around
+C-LeftArrow and C-RightArrow moves by words
Home/End go to begin/end of line
-C-Home/C-End go to begin/end of file
+C-Home/C-End go to begin/end of file
Some useful Emacs bindings are inherited from Tcl/Tk:
-
-
C-a beginning of line
-C-e end of line
-C-k kill line (but doesn’t put it in clipboard)
-C-l center window around the insertion point
-C-b go backward one character without deleting (usually you can +
C-a beginning of line
+C-e end of line
+C-k kill line (but doesn’t put it in clipboard)
+C-l center window around the insertion point
+C-b go backward one character without deleting (usually you can also use the cursor key for this)
-C-f go forward one character without deleting (usually you can +
C-f go forward one character without deleting (usually you can also use the cursor key for this)
-C-p go up one line (usually you can also use the cursor key for +
C-p go up one line (usually you can also use the cursor key for this)
-C-d delete next character
+C-d delete next character
C-c interrupts executing command
-C-d sends end-of-file; closes window if typed at a
>>>
prompt
-Alt-/ (Expand word) is also useful to reduce typing
+C-c interrupts executing command
+C-d sends end-of-file; closes window if typed at a
>>>
prompt
+Alt-/ (Expand word) is also useful to reduce typing
Command history
-
-
Alt-p retrieves previous command matching what you have typed. On -macOS use C-p.
-Alt-n retrieves next. On macOS use C-n.
-Return while on any previous command retrieves that command
+Alt-p retrieves previous command matching what you have typed. On +macOS use C-p.
+Alt-n retrieves next. On macOS use C-n.
+Return while the cursor is on any previous command +retrieves that command
Help menu (Shell and Editor)
-Editing and navigation¶
-
-Editor windows¶
+
+
+
+Editing and Navigation¶
+
+Editor windows¶
IDLE may open editor windows when it starts, depending on settings
and how you start IDLE. Thereafter, use the File menu. There can be only
one open editor window for a given file.
@@ -422,41 +521,41 @@ Editor windows
-Key bindings¶
+
+
+Key bindings¶
In this section, ‘C’ refers to the Control key on Windows and Unix and
the Command key on macOS.
-Standard keybindings (like C-c to copy and C-v to paste)
+
Standard keybindings (like C-c to copy and C-v to paste)
may work. Keybindings are selected in the Configure IDLE dialog.
-
-
-Automatic indentation¶
+
+
+Automatic indentation¶
After a block-opening statement, the next line is indented by 4 spaces (in the
Python Shell window by one tab). After certain keywords (break, return etc.)
the next line is dedented. In leading indentation, Backspace deletes up
@@ -465,9 +564,9 @@
Automatic indentation
See also the indent/dedent region commands on the
Format menu.
-
-
-Completions¶
+
+
+Completions¶
Completions are supplied, when requested and available, for module
names, attributes of classes or functions, or filenames. Each request
method displays a completion box with existing names. (See tab
@@ -489,7 +588,7 @@
Automatic indentation
Instead of waiting, or after a box is closed, open a completion box
immediately with Show Completions on the Edit menu. The default hot
-key is C-space. If one types a prefix for the desired name
+key is C-space. If one types a prefix for the desired name
before opening the box, the first match or near miss is made visible.
The result is the same as if one enters a prefix
after the box is displayed. Show Completions after a quote completes
@@ -509,9 +608,9 @@
Automatic indentationCompletion boxes initially exclude names beginning with ‘_’ or, for
modules, not included in ‘__all__’. The hidden names can be accessed
by typing ‘_’ after ‘.’, either before or after the box is opened.
-
-
-Calltips¶
+
+
+Calltips¶
A calltip is shown automatically when one types ( after the name
of an accessible function. A function name expression may include
dots and subscripts. A calltip remains until it is clicked, the cursor
@@ -535,9 +634,9 @@
Automatic indentationIn an editor, import statements have no effect until one runs the file.
One might want to run a file after writing import statements, after
adding function definitions, or after opening an existing file.
-
-
-Code Context¶
+
+
+Code Context¶
Within an editor window containing Python code, code context can be toggled
in order to show or hide a pane at the top of the window. When shown, this
pane freezes the opening lines for block code, such as those beginning with
@@ -550,33 +649,44 @@
Automatic indentation
The text and background colors for the context pane can be configured under
the Highlights tab in the Configure IDLE dialog.
-
-
-Python Shell window¶
-With IDLE’s Shell, one enters, edits, and recalls complete statements.
-Most consoles and terminals only work with a single physical line at a time.
+
+
+Shell window¶
+In IDLE’s Shell, enter, edit, and recall complete statements. (Most
+consoles and terminals only work with a single physical line at a time).
+Submit a single-line statement for execution by hitting Return
+with the cursor anywhere on the line. If a line is extended with
+Backslash (\), the cursor must be on the last physical line.
+Submit a multi-line compound statement by entering a blank line after
+the statement.
When one pastes code into Shell, it is not compiled and possibly executed
-until one hits Return. One may edit pasted code first.
-If one pastes more that one statement into Shell, the result will be a
+until one hits Return, as specified above.
+One may edit pasted code first.
+If one pastes more than one statement into Shell, the result will be a
SyntaxError
when multiple statements are compiled as if they were one.
+Lines containing`’RESTART’` mean that the user execution process has been
+re-started. This occurs when the user execution process has crashed,
+when one requests a restart on the Shell menu, or when one runs code
+in an editor window.
The editing features described in previous subsections work when entering
code interactively. IDLE’s Shell window also responds to the following keys.
-
-
-
-Text colors¶
+
+
+Text colors¶
Idle defaults to black on white text, but colors text with special meanings.
For the shell, these are shell output, shell error, user output, and
user error. For Python code, at the shell prompt or in an editor, these are
@@ -592,10 +702,10 @@
Text colors
-Startup and code execution¶
+
+
+
+Startup and Code Execution¶
Upon startup with the -s
option, IDLE will execute the file referenced by
the environment variables IDLESTARTUP
or PYTHONSTARTUP
.
IDLE first checks for IDLESTARTUP
; if IDLESTARTUP
is present the file
@@ -608,8 +718,8 @@
Startup and code execution
-Command line usage¶
+
+Command line usage¶
idle.py [-c command] [-d] [-e] [-h] [-i] [-r file] [-s] [-t title] [-] [arg] ...
-c command run command in the shell window
@@ -632,9 +742,9 @@ Command line usagesys.argv reflects the arguments passed to IDLE itself.
-
-
-Startup failure¶
+
+
+Startup failure¶
IDLE uses a socket to communicate between the IDLE GUI process and the user
code execution process. A connection must be established whenever the Shell
starts or restarts. (The latter is indicated by a divider line that says
@@ -684,9 +794,9 @@
Startup failure
-Running user code¶
+
+
+Running user code¶
With rare exceptions, the result of executing Python code with IDLE is
intended to be the same as executing the same code by the default method,
directly with Python in a text-mode system console or terminal window.
@@ -726,9 +836,9 @@
Running user code
-User output in Shell¶
+
+
+User output in Shell¶
When a program outputs text, the result is determined by the
corresponding output device. When IDLE executes user code, sys.stdout
and sys.stderr
are connected to the display area of IDLE’s Shell. Some of
@@ -780,9 +890,9 @@
User output in ShellSqueezed output is expanded in place by double-clicking the label.
It can also be sent to the clipboard or a separate view window by
right-clicking the label.
-
-
-Developing tkinter applications¶
+
+
+Developing tkinter applications¶
IDLE is intentionally different from standard Python in order to
facilitate development of tkinter programs. Enter import tkinter as tk;
root = tk.Tk()
in standard Python and nothing appears. Enter the same
@@ -800,9 +910,9 @@
Developing tkinter applications
-Running without a subprocess¶
+
+
+Running without a subprocess¶
By default, IDLE executes user code in a separate subprocess via a socket,
which uses the internal loopback interface. This connection is not
externally visible and no data is sent to or received from the internet.
@@ -825,12 +935,12 @@
Running without a subprocess
Deprecated since version 3.4.
-
-
-
-Help and preferences¶
-
-Help sources¶
+
+
+
+Help and Preferences¶
+
+Help sources¶
Help menu entry “IDLE Help” displays a formatted html version of the
IDLE chapter of the Library Reference. The result, in a read-only
tkinter text window, is close to what one sees in a web browser.
@@ -845,9 +955,9 @@
Help and preferences
Selected URLs can be added or removed from the help menu at any time using the
General tab of the Configure IDLE dialog.
-
-
-Setting preferences¶
+
+
+Setting preferences¶
The font preferences, highlighting, keys, and general preferences can be
changed via Configure IDLE on the Option menu.
Non-default user settings are saved in a .idlerc
directory in the user’s
@@ -863,23 +973,23 @@
Help and preferences
-
-
-IDLE on macOS¶
+
+
+IDLE on macOS¶
Under System Preferences: Dock, one can set “Prefer tabs when opening
documents” to “Always”. This setting is not compatible with the tk/tkinter
GUI framework used by IDLE, and it breaks a few IDLE features.
-
-
-Extensions¶
+
+
+Extensions¶
IDLE contains an extension facility. Preferences for extensions can be
changed with the Extensions tab of the preferences dialog. See the
beginning of config-extensions.def in the idlelib directory for further
information. The only current default extension is zzdummy, an example
also used for testing.
-
-
-
Editor windows¶
+ + +Editing and Navigation¶
+Editor windows¶
IDLE may open editor windows when it starts, depending on settings and how you start IDLE. Thereafter, use the File menu. There can be only one open editor window for a given file.
@@ -422,41 +521,41 @@Editor windows
-Key bindings¶
+
Key bindings¶
In this section, ‘C’ refers to the Control key on Windows and Unix and the Command key on macOS.
Standard keybindings (like C-c to copy and C-v to paste) +
Standard keybindings (like C-c to copy and C-v to paste) may work. Keybindings are selected in the Configure IDLE dialog.
-Automatic indentation¶
+ +Automatic indentation¶
After a block-opening statement, the next line is indented by 4 spaces (in the Python Shell window by one tab). After certain keywords (break, return etc.) the next line is dedented. In leading indentation, Backspace deletes up @@ -465,9 +564,9 @@
Automatic indentation
See also the indent/dedent region commands on the
Format menu.
-
Completions¶
+ +Completions¶
Completions are supplied, when requested and available, for module names, attributes of classes or functions, or filenames. Each request method displays a completion box with existing names. (See tab @@ -489,7 +588,7 @@
Automatic indentation
Instead of waiting, or after a box is closed, open a completion box
immediately with Show Completions on the Edit menu. The default hot
-key is C-space. If one types a prefix for the desired name
+key is C-space. If one types a prefix for the desired name
before opening the box, the first match or near miss is made visible.
The result is the same as if one enters a prefix
after the box is displayed. Show Completions after a quote completes
@@ -509,9 +608,9 @@
Automatic indentationCompletion boxes initially exclude names beginning with ‘_’ or, for
modules, not included in ‘__all__’. The hidden names can be accessed
by typing ‘_’ after ‘.’, either before or after the box is opened.
-
Calltips¶
+ +Calltips¶
A calltip is shown automatically when one types ( after the name of an accessible function. A function name expression may include dots and subscripts. A calltip remains until it is clicked, the cursor @@ -535,9 +634,9 @@
Automatic indentationIn an editor, import statements have no effect until one runs the file. One might want to run a file after writing import statements, after adding function definitions, or after opening an existing file. -
Code Context¶
+ +Code Context¶
Within an editor window containing Python code, code context can be toggled in order to show or hide a pane at the top of the window. When shown, this pane freezes the opening lines for block code, such as those beginning with @@ -550,33 +649,44 @@
Automatic indentation
The text and background colors for the context pane can be configured under
the Highlights tab in the Configure IDLE dialog.
-
Python Shell window¶
-With IDLE’s Shell, one enters, edits, and recalls complete statements. -Most consoles and terminals only work with a single physical line at a time.
+ +Shell window¶
+In IDLE’s Shell, enter, edit, and recall complete statements. (Most +consoles and terminals only work with a single physical line at a time).
+Submit a single-line statement for execution by hitting Return +with the cursor anywhere on the line. If a line is extended with +Backslash (\), the cursor must be on the last physical line. +Submit a multi-line compound statement by entering a blank line after +the statement.
When one pastes code into Shell, it is not compiled and possibly executed
-until one hits Return. One may edit pasted code first.
-If one pastes more that one statement into Shell, the result will be a
+until one hits Return, as specified above.
+One may edit pasted code first.
+If one pastes more than one statement into Shell, the result will be a
SyntaxError
when multiple statements are compiled as if they were one.
Lines containing`’RESTART’` mean that the user execution process has been +re-started. This occurs when the user execution process has crashed, +when one requests a restart on the Shell menu, or when one runs code +in an editor window.
The editing features described in previous subsections work when entering code interactively. IDLE’s Shell window also responds to the following keys.
-
-
Text colors¶
+ +Text colors¶
Idle defaults to black on white text, but colors text with special meanings. For the shell, these are shell output, shell error, user output, and user error. For Python code, at the shell prompt or in an editor, these are @@ -592,10 +702,10 @@
Text colors
-Startup and code execution¶
+
Startup and Code Execution¶
Upon startup with the -s
option, IDLE will execute the file referenced by
the environment variables IDLESTARTUP
or PYTHONSTARTUP
.
IDLE first checks for IDLESTARTUP
; if IDLESTARTUP
is present the file
@@ -608,8 +718,8 @@
Startup and code execution
-Command line usage¶
+
+Command line usage¶
idle.py [-c command] [-d] [-e] [-h] [-i] [-r file] [-s] [-t title] [-] [arg] ...
-c command run command in the shell window
@@ -632,9 +742,9 @@ Command line usagesys.argv reflects the arguments passed to IDLE itself.
-
-
-Startup failure¶
+
+
+Startup failure¶
IDLE uses a socket to communicate between the IDLE GUI process and the user
code execution process. A connection must be established whenever the Shell
starts or restarts. (The latter is indicated by a divider line that says
@@ -684,9 +794,9 @@
Startup failure
-Running user code¶
+
+
+Running user code¶
With rare exceptions, the result of executing Python code with IDLE is
intended to be the same as executing the same code by the default method,
directly with Python in a text-mode system console or terminal window.
@@ -726,9 +836,9 @@
Running user code
-User output in Shell¶
+
+
+User output in Shell¶
When a program outputs text, the result is determined by the
corresponding output device. When IDLE executes user code, sys.stdout
and sys.stderr
are connected to the display area of IDLE’s Shell. Some of
@@ -780,9 +890,9 @@
User output in ShellSqueezed output is expanded in place by double-clicking the label.
It can also be sent to the clipboard or a separate view window by
right-clicking the label.
-
-
-Developing tkinter applications¶
+
+
+Developing tkinter applications¶
IDLE is intentionally different from standard Python in order to
facilitate development of tkinter programs. Enter import tkinter as tk;
root = tk.Tk()
in standard Python and nothing appears. Enter the same
@@ -800,9 +910,9 @@
Developing tkinter applications
-Running without a subprocess¶
+
+
+Running without a subprocess¶
By default, IDLE executes user code in a separate subprocess via a socket,
which uses the internal loopback interface. This connection is not
externally visible and no data is sent to or received from the internet.
@@ -825,12 +935,12 @@
Running without a subprocess
Deprecated since version 3.4.
-
-
Command line usage¶
idle.py [-c command] [-d] [-e] [-h] [-i] [-r file] [-s] [-t title] [-] [arg] ...
-c command run command in the shell window
@@ -632,9 +742,9 @@ Command line usagesys.argv reflects the arguments passed to IDLE itself.
-
Startup failure¶
+ +Startup failure¶
IDLE uses a socket to communicate between the IDLE GUI process and the user code execution process. A connection must be established whenever the Shell starts or restarts. (The latter is indicated by a divider line that says @@ -684,9 +794,9 @@
Startup failure
-Running user code¶
+
Running user code¶
With rare exceptions, the result of executing Python code with IDLE is intended to be the same as executing the same code by the default method, directly with Python in a text-mode system console or terminal window. @@ -726,9 +836,9 @@
Running user code
-User output in Shell¶
+
User output in Shell¶
When a program outputs text, the result is determined by the
corresponding output device. When IDLE executes user code, sys.stdout
and sys.stderr
are connected to the display area of IDLE’s Shell. Some of
@@ -780,9 +890,9 @@
User output in ShellSqueezed output is expanded in place by double-clicking the label. It can also be sent to the clipboard or a separate view window by right-clicking the label. -
Developing tkinter applications¶
+ +Developing tkinter applications¶
IDLE is intentionally different from standard Python in order to
facilitate development of tkinter programs. Enter import tkinter as tk;
root = tk.Tk()
in standard Python and nothing appears. Enter the same
@@ -800,9 +910,9 @@
Developing tkinter applications
-Running without a subprocess¶
+
Running without a subprocess¶
By default, IDLE executes user code in a separate subprocess via a socket, which uses the internal loopback interface. This connection is not externally visible and no data is sent to or received from the internet. @@ -825,12 +935,12 @@
Running without a subprocess
Deprecated since version 3.4.
Help and preferences¶
-Help sources¶
+ + +Help and Preferences¶
+Help sources¶
Help menu entry “IDLE Help” displays a formatted html version of the IDLE chapter of the Library Reference. The result, in a read-only tkinter text window, is close to what one sees in a web browser. @@ -845,9 +955,9 @@
Help and preferences
Selected URLs can be added or removed from the help menu at any time using the
General tab of the Configure IDLE dialog.
-
Setting preferences¶
+ +Setting preferences¶
The font preferences, highlighting, keys, and general preferences can be
changed via Configure IDLE on the Option menu.
Non-default user settings are saved in a .idlerc
directory in the user’s
@@ -863,23 +973,23 @@
Help and preferences -
IDLE on macOS¶
+ +IDLE on macOS¶
Under System Preferences: Dock, one can set “Prefer tabs when opening documents” to “Always”. This setting is not compatible with the tk/tkinter GUI framework used by IDLE, and it breaks a few IDLE features.
-Extensions¶
+ +Extensions¶
IDLE contains an extension facility. Preferences for extensions can be changed with the Extensions tab of the preferences dialog. See the beginning of config-extensions.def in the idlelib directory for further information. The only current default extension is zzdummy, an example also used for testing.
-Extensions
- Table of Contents
-
+
+ Table of Contents
+
- IDLE
- Menus
-- Editing and navigation
+- Editing and Navigation
-- Startup and code execution
+- Startup and Code Execution
- Command line usage
- Startup failure
- Running user code
@@ -924,7 +1035,7 @@ Table of Contents
- Running without a subprocess
-- Help and preferences
+- Help and Preferences
- Help sources
- Setting preferences
- IDLE on macOS
@@ -935,12 +1046,17 @@ Table of Contents
- Previous topic
- tkinter.tix
— Extension widgets for Tk
- Next topic
-
+
+
+ Previous topic
+
+
+
+ Next topic
+
+
This Page
@@ -953,6 +1069,10 @@ This Page
+
+«
+
+
Table of Contents
--
+
- IDLE
- Menus -
- Editing and navigation
-
+
- Editing and Navigation -
- Startup and code execution
-
+
- Startup and Code Execution
- Command line usage
- Startup failure
- Running user code @@ -924,7 +1035,7 @@
- Running without a subprocess
Table of Contents
- - Help and preferences
-
+
- Help and Preferences
- Help sources
- Setting preferences
- IDLE on macOS @@ -935,12 +1046,17 @@
Table of Contents
Previous topic
-
-tkinter.tix
— Extension widgets for TkNext topic
- + - Help and Preferences
- Startup and Code Execution
Table of Contents
+Previous topic
+ +Next topic
+ +This Page
-
@@ -953,6 +1069,10 @@
This Page
Navigation
previous | - -+ This page is licensed under the Python Software Foundation License Version 2. +
+ Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License. +
+ See History and License for more information.
+
The Python Software Foundation is a non-profit corporation. Please donate.
- Last updated on Jan 26, 2022. + Last updated on Jun 26, 2022. Found a bug?
- Created using Sphinx 3.2.1. + Created using Sphinx 5.0.2.
tags after a closed tag.