blob: bc4a791ed2e0756b53a4156f5350df9beadad05f [file] [log] [blame]
Georg Brandl116aa622007-08-15 14:28:22 +00001.. _idle:
2
Georg Brandl116aa622007-08-15 14:28:22 +00003.. index::
Christian Heimes5b5e81c2007-12-31 16:14:33 +00004 single: IDLE
Georg Brandl116aa622007-08-15 14:28:22 +00005 single: Python Editor
6 single: Integrated Development Environment
7
Terry Jan Reedyf5684942014-12-04 00:54:59 -05008IDLE
9====
10
11.. moduleauthor:: Guido van Rossum <guido@Python.org>
12
Georg Brandlac6060c2008-05-17 18:44:45 +000013IDLE is the Python IDE built with the :mod:`tkinter` GUI toolkit.
Georg Brandl116aa622007-08-15 14:28:22 +000014
15IDLE has the following features:
16
Georg Brandlac6060c2008-05-17 18:44:45 +000017* coded in 100% pure Python, using the :mod:`tkinter` GUI toolkit
Georg Brandl116aa622007-08-15 14:28:22 +000018
Andrew Svetlov1bd7f022013-01-14 19:27:36 +020019* cross-platform: works on Windows, Unix, and Mac OS X
Georg Brandl116aa622007-08-15 14:28:22 +000020
Andrew Svetlov1bd7f022013-01-14 19:27:36 +020021* multi-window text editor with multiple undo, Python colorizing,
22 smart indent, call tips, and many other features
Georg Brandl116aa622007-08-15 14:28:22 +000023
24* Python shell window (a.k.a. interactive interpreter)
25
Andrew Svetlov1bd7f022013-01-14 19:27:36 +020026* debugger (not complete, but you can set breakpoints, view and step)
Georg Brandl116aa622007-08-15 14:28:22 +000027
28
29Menus
30-----
31
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -050032IDLE has two main window types, the Shell window and the Editor window. It is
33possible to have multiple editor windows simultaneously. Output windows, such
34as used for Edit / Find in Files, are a subtype of edit window. They currently
35have the same top menu as Editor windows but a different default title and
36context menu.
37
38IDLE's menus dynamically change based on which window is currently selected.
39Each menu documented below indicates which window type it is associated with.
40Click on the dotted line at the top of a menu to "tear it off": a separate
41window containing the menu is created (for Unix and Windows only).
Georg Brandl116aa622007-08-15 14:28:22 +000042
Andrew Svetlov1bd7f022013-01-14 19:27:36 +020043File menu (Shell and Editor)
44^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Georg Brandl116aa622007-08-15 14:28:22 +000045
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -050046New File
47 Create a new file editing window.
Georg Brandl116aa622007-08-15 14:28:22 +000048
49Open...
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -050050 Open an existing file with an Open dialog.
Andrew Svetlov1bd7f022013-01-14 19:27:36 +020051
52Recent Files
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -050053 Open a list of recent files. Click one to open it.
54
55Open Module...
56 Open an existing module (searches sys.path).
Georg Brandl116aa622007-08-15 14:28:22 +000057
Terry Jan Reedyf5684942014-12-04 00:54:59 -050058.. index::
59 single: Class browser
60 single: Path browser
61
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -050062Class Browser
63 Show functions, classes, and methods in the current Editor file in a
64 tree structure. In the shell, open a module first.
Georg Brandl116aa622007-08-15 14:28:22 +000065
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -050066Path Browser
67 Show sys.path directories, modules, functions, classes and methods in a
68 tree structure.
Georg Brandl116aa622007-08-15 14:28:22 +000069
Georg Brandl116aa622007-08-15 14:28:22 +000070Save
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -050071 Save the current window to the associated file, if there is one. Windows
72 that have been changed since being opened or last saved have a \* before
73 and after the window title. If there is no associated file,
74 do Save As instead.
Georg Brandl116aa622007-08-15 14:28:22 +000075
76Save As...
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -050077 Save the current window with a Save As dialog. The file saved becomes the
78 new associated file for the window.
Georg Brandl116aa622007-08-15 14:28:22 +000079
80Save Copy As...
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -050081 Save the current window to different file without changing the associated
82 file.
Andrew Svetlov1bd7f022013-01-14 19:27:36 +020083
84Print Window
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -050085 Print the current window to the default printer.
Georg Brandl116aa622007-08-15 14:28:22 +000086
87Close
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -050088 Close the current window (ask to save if unsaved).
Georg Brandl116aa622007-08-15 14:28:22 +000089
90Exit
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -050091 Close all windows and quit IDLE (ask to save unsaved windows).
Georg Brandl116aa622007-08-15 14:28:22 +000092
Andrew Svetlov1bd7f022013-01-14 19:27:36 +020093Edit menu (Shell and Editor)
94^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Georg Brandl116aa622007-08-15 14:28:22 +000095
96Undo
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -050097 Undo the last change to the current window. A maximum of 1000 changes may
98 be undone.
Georg Brandl116aa622007-08-15 14:28:22 +000099
100Redo
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500101 Redo the last undone change to the current window.
Georg Brandl116aa622007-08-15 14:28:22 +0000102
103Cut
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500104 Copy selection into the system-wide clipboard; then delete the selection.
Georg Brandl116aa622007-08-15 14:28:22 +0000105
106Copy
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500107 Copy selection into the system-wide clipboard.
Georg Brandl116aa622007-08-15 14:28:22 +0000108
109Paste
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500110 Insert contents of the system-wide clipboard into the current window.
111
112The clipboard functions are also available in context menus.
Georg Brandl116aa622007-08-15 14:28:22 +0000113
114Select All
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500115 Select the entire contents of the current window.
Georg Brandl116aa622007-08-15 14:28:22 +0000116
117Find...
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500118 Open a search dialog with many options
Georg Brandl116aa622007-08-15 14:28:22 +0000119
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500120Find Again
121 Repeat the last search, if there is one.
Georg Brandl116aa622007-08-15 14:28:22 +0000122
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500123Find Selection
124 Search for the currently selected string, if there is one.
Georg Brandl116aa622007-08-15 14:28:22 +0000125
126Find in Files...
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500127 Open a file search dialog. Put results in an new output window.
Georg Brandl116aa622007-08-15 14:28:22 +0000128
129Replace...
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500130 Open a search-and-replace dialog.
Georg Brandl116aa622007-08-15 14:28:22 +0000131
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500132Go to Line
133 Move cursor to the line number requested and make that line visible.
Georg Brandl116aa622007-08-15 14:28:22 +0000134
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500135Show Completions
136 Open a scrollable list allowing selection of keywords and attributes. See
137 Completions in the Tips sections below.
138
139Expand Word
140 Expand a prefix you have typed to match a full word in the same window;
141 repeat to get a different expansion.
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200142
143Show call tip
144 After an unclosed parenthesis for a function, open a small window with
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500145 function parameter hints.
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200146
147Show surrounding parens
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500148 Highlight the surrounding parenthesis.
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200149
150Format menu (Editor window only)
Terry Jan Reedyf5684942014-12-04 00:54:59 -0500151^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200152
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500153Indent Region
154 Shift selected lines right by the indent width (default 4 spaces).
Georg Brandl116aa622007-08-15 14:28:22 +0000155
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500156Dedent Region
157 Shift selected lines left by the indent width (default 4 spaces).
Georg Brandl116aa622007-08-15 14:28:22 +0000158
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500159Comment Out Region
160 Insert ## in front of selected lines.
Georg Brandl116aa622007-08-15 14:28:22 +0000161
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500162Uncomment Region
163 Remove leading # or ## from selected lines.
Georg Brandl116aa622007-08-15 14:28:22 +0000164
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500165Tabify Region
166 Turn *leading* stretches of spaces into tabs. (Note: We recommend using
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200167 4 space blocks to indent Python code.)
Georg Brandl116aa622007-08-15 14:28:22 +0000168
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500169Untabify Region
170 Turn *all* tabs into the correct number of spaces.
Georg Brandl116aa622007-08-15 14:28:22 +0000171
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500172Toggle Tabs
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200173 Open a dialog to switch between indenting with spaces and tabs.
174
175New Indent Width
176 Open a dialog to change indent width. The accepted default by the Python
177 community is 4 spaces.
Georg Brandl116aa622007-08-15 14:28:22 +0000178
179Format Paragraph
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500180 Reformat the current blank-line-delimited paragraph in comment block or
181 multiline string or selected line in a string. All lines in the
182 paragraph will be formatted to less than N columns, where N defaults to 72.
Georg Brandl116aa622007-08-15 14:28:22 +0000183
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200184Strip trailing whitespace
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500185 Remove any space characters after the last non-space character of a line.
Georg Brandl116aa622007-08-15 14:28:22 +0000186
187.. index::
Georg Brandl116aa622007-08-15 14:28:22 +0000188 single: Run script
189
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200190Run menu (Editor window only)
191^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Georg Brandl116aa622007-08-15 14:28:22 +0000192
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200193Python Shell
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500194 Open or wake up the Python Shell window.
Georg Brandl116aa622007-08-15 14:28:22 +0000195
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500196Check Module
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200197 Check the syntax of the module currently open in the Editor window. If the
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500198 module has not been saved IDLE will either prompt the user to save or
199 autosave, as selected in the General tab of the Idle Settings dialog. If
200 there is a syntax error, the approximate location is indicated in the
201 Editor window.
Georg Brandl116aa622007-08-15 14:28:22 +0000202
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500203Run Module
204 Do Check Module (above). If no error, restart the shell to clean the
205 environment, then execute the module.
Georg Brandl116aa622007-08-15 14:28:22 +0000206
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200207Shell menu (Shell window only)
208^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Ned Deily2778d0d2012-10-20 13:25:34 -0700209
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200210View Last Restart
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500211 Scroll the shell window to the last Shell restart.
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200212
213Restart Shell
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500214 Restart the shell to clean the environment.
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200215
216Debug menu (Shell window only)
217^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Georg Brandl116aa622007-08-15 14:28:22 +0000218
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500219Go to File/Line
220 Look on the current line. with the cursor, and the line above for a filename
221 and line number. If found, open the file if not already open, and show the
222 line. Use this to view source lines referenced in an exception traceback
223 and lines found by Find in Files. Also available in the context menu of
224 the Shell window and Output windows.
Georg Brandl116aa622007-08-15 14:28:22 +0000225
226.. index::
Georg Brandl116aa622007-08-15 14:28:22 +0000227 single: debugger
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500228 single: stack viewer
229
230Debugger (toggle)
231 When actived, code entered in the Shell or run from an Editor will run
232 under the debugger. In the Editor, breakpoints can be set with the context
233 menu. This feature is still incomplete and somewhat experimental.
234
235Stack Viewer
236 Show the stack traceback of the last exception in a tree widget, with
237 access to locals and globals.
238
239Auto-open Stack Viewer
240 Toggle automatically opening the stack viewer on an unhandled exception.
Georg Brandl116aa622007-08-15 14:28:22 +0000241
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200242Options menu (Shell and Editor)
243^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Georg Brandl116aa622007-08-15 14:28:22 +0000244
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200245Configure IDLE
246 Open a configuration dialog. Fonts, indentation, keybindings, and color
247 themes may be altered. Startup Preferences may be set, and additional
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500248 help sources can be specified. Non-default user setting are saved in a
249 .idlerc directory in the user's home directory. Problems caused by bad user
250 configuration files are solved by editing or deleting one or more of the
251 files in .idlerc.
Ned Deily2778d0d2012-10-20 13:25:34 -0700252
Terry Jan Reedybb37b4c2014-12-04 01:26:04 -0500253Configure Extensions
254 Open a configuration dialog for setting preferences for extensions
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500255 (discussed below). See note above about the location of user settings.
Terry Jan Reedybb37b4c2014-12-04 01:26:04 -0500256
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200257Code Context (toggle)(Editor Window only)
258 Open a pane at the top of the edit window which shows the block context
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500259 of the code which has scrolled above the top of the window.
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200260
Ned Deilyccb416f2015-01-17 21:06:27 -0800261Window menu (Shell and Editor)
262^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200263
264Zoom Height
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500265 Toggles the window between normal size and maximum height. The initial size
266 defaults to 40 lines by 80 chars unless changed on the General tab of the
267 Configure IDLE dialog.
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200268
269The rest of this menu lists the names of all open windows; select one to bring
270it to the foreground (deiconifying it if necessary).
271
272Help menu (Shell and Editor)
273^^^^^^^^^^^^^^^^^^^^^^^^^^^^
274
275About IDLE
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500276 Display version, copyright, license, credits, and more.
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200277
278IDLE Help
279 Display a help file for IDLE detailing the menu options, basic editing and
280 navigation, and other tips.
281
282Python Docs
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500283 Access local Python documentation, if installed, or start a web browser
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200284 and open docs.python.org showing the latest Python documentation.
285
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500286Turtle Demo
287 Run the turtledemo module with example python code and turtle drawings.
288
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200289Additional help sources may be added here with the Configure IDLE dialog under
290the General tab.
291
Terry Jan Reedyf5684942014-12-04 00:54:59 -0500292.. index::
293 single: Cut
294 single: Copy
295 single: Paste
296 single: Set Breakpoint
297 single: Clear Breakpoint
298 single: breakpoints
299
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500300Context Menus
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200301^^^^^^^^^^^^^^^^^^^^^^^^^^
302
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500303Open a context menu by right-clicking in a window (Control-click on OS X).
304Context menus have the standard clipboard functions also on the Edit menu.
Ned Deily2778d0d2012-10-20 13:25:34 -0700305
Andrew Svetlovd1837672012-11-01 22:41:19 +0200306Cut
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500307 Copy selection into the system-wide clipboard; then delete the selection.
Andrew Svetlovd1837672012-11-01 22:41:19 +0200308
309Copy
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500310 Copy selection into the system-wide clipboard.
Andrew Svetlovd1837672012-11-01 22:41:19 +0200311
312Paste
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500313 Insert contents of the system-wide clipboard into the current window.
314
315Editor windows also have breakpoint functions. Lines with a breakpoint set are
316specially marked. Breakpoints only have an effect when running under the
317debugger. Breakpoints for a file are saved in the user's .idlerc directory.
Andrew Svetlovd1837672012-11-01 22:41:19 +0200318
Ned Deily2778d0d2012-10-20 13:25:34 -0700319Set Breakpoint
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500320 Set a breakpoint on the current line.
Ned Deily2778d0d2012-10-20 13:25:34 -0700321
322Clear Breakpoint
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500323 Clear the breakpoint on that line.
Ned Deily2778d0d2012-10-20 13:25:34 -0700324
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500325Shell and Output windows have the following.
Andrew Svetlovd1837672012-11-01 22:41:19 +0200326
Ned Deily2778d0d2012-10-20 13:25:34 -0700327Go to file/line
328 Same as in Debug menu.
329
330
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200331Editing and navigation
332----------------------
Georg Brandl116aa622007-08-15 14:28:22 +0000333
Terry Jan Reedyf5684942014-12-04 00:54:59 -0500334In this section, 'C' refers to the Control key on Windows and Unix and
335the Command key on Mac OSX.
336
Georg Brandl116aa622007-08-15 14:28:22 +0000337* :kbd:`Backspace` deletes to the left; :kbd:`Del` deletes to the right
338
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200339* :kbd:`C-Backspace` delete word left; :kbd:`C-Del` delete word to the right
340
Georg Brandl116aa622007-08-15 14:28:22 +0000341* Arrow keys and :kbd:`Page Up`/:kbd:`Page Down` to move around
342
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200343* :kbd:`C-LeftArrow` and :kbd:`C-RightArrow` moves by words
344
Georg Brandl116aa622007-08-15 14:28:22 +0000345* :kbd:`Home`/:kbd:`End` go to begin/end of line
346
347* :kbd:`C-Home`/:kbd:`C-End` go to begin/end of file
348
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200349* Some useful Emacs bindings are inherited from Tcl/Tk:
350
351 * :kbd:`C-a` beginning of line
352
353 * :kbd:`C-e` end of line
354
355 * :kbd:`C-k` kill line (but doesn't put it in clipboard)
356
357 * :kbd:`C-l` center window around the insertion point
358
359 * :kbd:`C-b` go backwards one character without deleting (usually you can
360 also use the cursor key for this)
361
362 * :kbd:`C-f` go forward one character without deleting (usually you can
363 also use the cursor key for this)
364
365 * :kbd:`C-p` go up one line (usually you can also use the cursor key for
366 this)
367
368 * :kbd:`C-d` delete next character
369
370Standard keybindings (like :kbd:`C-c` to copy and :kbd:`C-v` to paste)
371may work. Keybindings are selected in the Configure IDLE dialog.
Georg Brandl116aa622007-08-15 14:28:22 +0000372
373
374Automatic indentation
375^^^^^^^^^^^^^^^^^^^^^
376
377After a block-opening statement, the next line is indented by 4 spaces (in the
378Python Shell window by one tab). After certain keywords (break, return etc.)
379the next line is dedented. In leading indentation, :kbd:`Backspace` deletes up
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200380to 4 spaces if they are there. :kbd:`Tab` inserts spaces (in the Python
381Shell window one tab), number depends on Indent width. Currently tabs
382are restricted to four spaces due to Tcl/Tk limitations.
Georg Brandl116aa622007-08-15 14:28:22 +0000383
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200384See also the indent/dedent region commands in the edit menu.
385
386Completions
387^^^^^^^^^^^
388
389Completions are supplied for functions, classes, and attributes of classes,
390both built-in and user-defined. Completions are also provided for
391filenames.
392
393The AutoCompleteWindow (ACW) will open after a predefined delay (default is
394two seconds) after a '.' or (in a string) an os.sep is typed. If after one
395of those characters (plus zero or more other characters) a tab is typed
396the ACW will open immediately if a possible continuation is found.
397
398If there is only one possible completion for the characters entered, a
399:kbd:`Tab` will supply that completion without opening the ACW.
400
401'Show Completions' will force open a completions window, by default the
402:kbd:`C-space` will open a completions window. In an empty
403string, this will contain the files in the current directory. On a
404blank line, it will contain the built-in and user-defined functions and
405classes in the current name spaces, plus any modules imported. If some
406characters have been entered, the ACW will attempt to be more specific.
407
408If a string of characters is typed, the ACW selection will jump to the
409entry most closely matching those characters. Entering a :kbd:`tab` will
410cause the longest non-ambiguous match to be entered in the Editor window or
411Shell. Two :kbd:`tab` in a row will supply the current ACW selection, as
412will return or a double click. Cursor keys, Page Up/Down, mouse selection,
413and the scroll wheel all operate on the ACW.
414
415"Hidden" attributes can be accessed by typing the beginning of hidden
416name after a '.', e.g. '_'. This allows access to modules with
417``__all__`` set, or to class-private attributes.
418
419Completions and the 'Expand Word' facility can save a lot of typing!
420
421Completions are currently limited to those in the namespaces. Names in
422an Editor window which are not via ``__main__`` and :data:`sys.modules` will
423not be found. Run the module once with your imports to correct this situation.
424Note that IDLE itself places quite a few modules in sys.modules, so
425much can be found by default, e.g. the re module.
426
427If you don't like the ACW popping up unbidden, simply make the delay
428longer or disable the extension. Or another option is the delay could
429be set to zero. Another alternative to preventing ACW popups is to
430disable the call tips extension.
Georg Brandl116aa622007-08-15 14:28:22 +0000431
432Python Shell window
433^^^^^^^^^^^^^^^^^^^
434
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200435* :kbd:`C-c` interrupts executing command
Georg Brandl116aa622007-08-15 14:28:22 +0000436
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200437* :kbd:`C-d` sends end-of-file; closes window if typed at a ``>>>`` prompt
Georg Brandl116aa622007-08-15 14:28:22 +0000438
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200439* :kbd:`Alt-/` (Expand word) is also useful to reduce typing
Georg Brandl116aa622007-08-15 14:28:22 +0000440
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200441 Command history
Georg Brandl116aa622007-08-15 14:28:22 +0000442
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200443 * :kbd:`Alt-p` retrieves previous command matching what you have typed. On
444 OS X use :kbd:`C-p`.
Georg Brandl116aa622007-08-15 14:28:22 +0000445
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200446 * :kbd:`Alt-n` retrieves next. On OS X use :kbd:`C-n`.
Georg Brandl116aa622007-08-15 14:28:22 +0000447
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200448 * :kbd:`Return` while on any previous command retrieves that command
Georg Brandl116aa622007-08-15 14:28:22 +0000449
450
451Syntax colors
452-------------
453
454The coloring is applied in a background "thread," so you may occasionally see
455uncolorized text. To change the color scheme, edit the ``[Colors]`` section in
456:file:`config.txt`.
457
458Python syntax colors:
459 Keywords
460 orange
461
Georg Brandl48310cd2009-01-03 21:18:54 +0000462 Strings
Georg Brandl116aa622007-08-15 14:28:22 +0000463 green
464
465 Comments
466 red
467
468 Definitions
469 blue
470
471Shell colors:
472 Console output
473 brown
474
475 stdout
476 blue
477
478 stderr
479 dark green
480
481 stdin
482 black
483
484
Benjamin Petersonf07d0022009-03-21 17:31:58 +0000485Startup
486-------
487
488Upon startup with the ``-s`` option, IDLE will execute the file referenced by
489the environment variables :envvar:`IDLESTARTUP` or :envvar:`PYTHONSTARTUP`.
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200490IDLE first checks for ``IDLESTARTUP``; if ``IDLESTARTUP`` is present the file
491referenced is run. If ``IDLESTARTUP`` is not present, IDLE checks for
Benjamin Petersonf07d0022009-03-21 17:31:58 +0000492``PYTHONSTARTUP``. Files referenced by these environment variables are
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200493convenient places to store functions that are used frequently from the IDLE
Benjamin Petersonf07d0022009-03-21 17:31:58 +0000494shell, or for executing import statements to import common modules.
495
496In addition, ``Tk`` also loads a startup file if it is present. Note that the
497Tk file is loaded unconditionally. This additional file is ``.Idle.py`` and is
498looked for in the user's home directory. Statements in this file will be
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500499executed in the Tk namespace, so this file is not useful for importing
500functions to be used from IDLE's Python shell.
Benjamin Petersonf07d0022009-03-21 17:31:58 +0000501
502
Georg Brandl116aa622007-08-15 14:28:22 +0000503Command line usage
504^^^^^^^^^^^^^^^^^^
505
506::
507
508 idle.py [-c command] [-d] [-e] [-s] [-t title] [arg] ...
509
510 -c command run this command
511 -d enable debugger
512 -e edit mode; arguments are files to be edited
513 -s run $IDLESTARTUP or $PYTHONSTARTUP first
514 -t title set title of shell window
515
516If there are arguments:
517
Éric Araujo713d3032010-11-18 16:38:46 +0000518#. If ``-e`` is used, arguments are files opened for editing and
Georg Brandl116aa622007-08-15 14:28:22 +0000519 ``sys.argv`` reflects the arguments passed to IDLE itself.
520
Éric Araujo713d3032010-11-18 16:38:46 +0000521#. Otherwise, if ``-c`` is used, all arguments are placed in
Georg Brandl116aa622007-08-15 14:28:22 +0000522 ``sys.argv[1:...]``, with ``sys.argv[0]`` set to ``'-c'``.
523
Éric Araujo713d3032010-11-18 16:38:46 +0000524#. Otherwise, if neither ``-e`` nor ``-c`` is used, the first
Georg Brandl116aa622007-08-15 14:28:22 +0000525 argument is a script which is executed with the remaining arguments in
Terry Jan Reedy3ab745e2014-12-05 02:43:07 -0500526 ``sys.argv[1:...]`` and ``sys.argv[0]`` set to the script name. If the
527 script name is '-', no script is executed but an interactive Python session
528 is started; the arguments are still available in ``sys.argv``.
Georg Brandl116aa622007-08-15 14:28:22 +0000529
Terry Jan Reedyf5684942014-12-04 00:54:59 -0500530Running without a subprocess
531^^^^^^^^^^^^^^^^^^^^^^^^^^^^
532
533If IDLE is started with the -n command line switch it will run in a
534single process and will not create the subprocess which runs the RPC
535Python execution server. This can be useful if Python cannot create
536the subprocess or the RPC socket interface on your platform. However,
537in this mode user code is not isolated from IDLE itself. Also, the
538environment is not restarted when Run/Run Module (F5) is selected. If
539your code has been modified, you must reload() the affected modules and
540re-import any specific items (e.g. from foo import baz) if the changes
541are to take effect. For these reasons, it is preferable to run IDLE
542with the default subprocess if at all possible.
543
544.. deprecated:: 3.4
545
Georg Brandl116aa622007-08-15 14:28:22 +0000546
Terry Jan Reedybb37b4c2014-12-04 01:26:04 -0500547Help and preferences
548--------------------
549
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200550Additional help sources
Terry Jan Reedybb37b4c2014-12-04 01:26:04 -0500551^^^^^^^^^^^^^^^^^^^^^^^
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200552
553IDLE includes a help menu entry called "Python Docs" that will open the
554extensive sources of help, including tutorials, available at docs.python.org.
555Selected URLs can be added or removed from the help menu at any time using the
556Configure IDLE dialog. See the IDLE help option in the help menu of IDLE for
557more information.
558
559
Terry Jan Reedybb37b4c2014-12-04 01:26:04 -0500560Setting preferences
561^^^^^^^^^^^^^^^^^^^
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200562
563The font preferences, highlighting, keys, and general preferences can be
Terry Jan Reedybb37b4c2014-12-04 01:26:04 -0500564changed via Configure IDLE on the Option menu. Keys can be user defined;
565IDLE ships with four built in key sets. In addition a user can create a
566custom key set in the Configure IDLE dialog under the keys tab.
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200567
Terry Jan Reedyf5684942014-12-04 00:54:59 -0500568
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200569Extensions
Terry Jan Reedybb37b4c2014-12-04 01:26:04 -0500570^^^^^^^^^^
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200571
Terry Jan Reedybb37b4c2014-12-04 01:26:04 -0500572IDLE contains an extension facility. Peferences for extensions can be
573changed with Configure Extensions. See the beginning of config-extensions.def
574in the idlelib directory for further information. The default extensions
575are currently:
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200576
577* FormatParagraph
578
579* AutoExpand
580
581* ZoomHeight
582
583* ScriptBinding
584
585* CallTips
586
587* ParenMatch
588
589* AutoComplete
590
591* CodeContext
592
Terry Jan Reedybb37b4c2014-12-04 01:26:04 -0500593* RstripExtension