blob: 24e22c103de7536a9f158810eeab0596922ea46f [file] [log] [blame]
Georg Brandl8ec7f652007-08-15 14:28:01 +00001.. _idle:
2
Ned Deilye0944c92015-02-06 15:41:27 +11003IDLE
4====
5
Georg Brandl8ec7f652007-08-15 14:28:01 +00006.. index::
Georg Brandlb19be572007-12-29 10:57:00 +00007 single: IDLE
Georg Brandl8ec7f652007-08-15 14:28:01 +00008 single: Python Editor
9 single: Integrated Development Environment
10
Terry Jan Reedyeb405892014-12-04 00:55:46 -050011.. moduleauthor:: Guido van Rossum <guido@Python.org>
12
Georg Brandlc21cd7e2008-05-16 17:37:53 +000013IDLE is the Python IDE built with the :mod:`tkinter` GUI toolkit.
Georg Brandl8ec7f652007-08-15 14:28:01 +000014
15IDLE has the following features:
16
Georg Brandlc21cd7e2008-05-16 17:37:53 +000017* coded in 100% pure Python, using the :mod:`tkinter` GUI toolkit
Georg Brandl8ec7f652007-08-15 14:28:01 +000018
Terry Jan Reedyeb405892014-12-04 00:55:46 -050019* cross-platform: works on Windows, Unix, and Mac OS X
Georg Brandl8ec7f652007-08-15 14:28:01 +000020
Terry Jan Reedyeb405892014-12-04 00:55:46 -050021* multi-window text editor with multiple undo, Python colorizing,
22 smart indent, call tips, and many other features
Georg Brandl8ec7f652007-08-15 14:28:01 +000023
24* Python shell window (a.k.a. interactive interpreter)
25
Terry Jan Reedyeb405892014-12-04 00:55:46 -050026* debugger (not complete, but you can set breakpoints, view and step)
Georg Brandl8ec7f652007-08-15 14:28:01 +000027
28
29Menus
30-----
31
Terry Jan Reedybafef5a2014-12-05 02:42:54 -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 Brandl8ec7f652007-08-15 14:28:01 +000042
Terry Jan Reedyeb405892014-12-04 00:55:46 -050043File menu (Shell and Editor)
44^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Georg Brandl8ec7f652007-08-15 14:28:01 +000045
Terry Jan Reedybafef5a2014-12-05 02:42:54 -050046New File
47 Create a new file editing window.
Georg Brandl8ec7f652007-08-15 14:28:01 +000048
49Open...
Terry Jan Reedybafef5a2014-12-05 02:42:54 -050050 Open an existing file with an Open dialog.
Georg Brandl8ec7f652007-08-15 14:28:01 +000051
Terry Jan Reedyeb405892014-12-04 00:55:46 -050052Recent Files
Terry Jan Reedybafef5a2014-12-05 02:42:54 -050053 Open a list of recent files. Click one to open it.
54
55Open Module...
56 Open an existing module (searches sys.path).
Georg Brandl8ec7f652007-08-15 14:28:01 +000057
58.. index::
59 single: Class browser
60 single: Path browser
61
Terry Jan Reedybafef5a2014-12-05 02:42:54 -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.
Terry Jan Reedyeb405892014-12-04 00:55:46 -050065
Terry Jan Reedybafef5a2014-12-05 02:42:54 -050066Path Browser
67 Show sys.path directories, modules, functions, classes and methods in a
68 tree structure.
Terry Jan Reedyeb405892014-12-04 00:55:46 -050069
Georg Brandl8ec7f652007-08-15 14:28:01 +000070Save
Terry Jan Reedybafef5a2014-12-05 02:42:54 -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 Brandl8ec7f652007-08-15 14:28:01 +000075
76Save As...
Terry Jan Reedybafef5a2014-12-05 02:42:54 -050077 Save the current window with a Save As dialog. The file saved becomes the
78 new associated file for the window.
Georg Brandl8ec7f652007-08-15 14:28:01 +000079
80Save Copy As...
Terry Jan Reedybafef5a2014-12-05 02:42:54 -050081 Save the current window to different file without changing the associated
82 file.
Terry Jan Reedyeb405892014-12-04 00:55:46 -050083
84Print Window
Terry Jan Reedybafef5a2014-12-05 02:42:54 -050085 Print the current window to the default printer.
Georg Brandl8ec7f652007-08-15 14:28:01 +000086
87Close
Terry Jan Reedybafef5a2014-12-05 02:42:54 -050088 Close the current window (ask to save if unsaved).
Georg Brandl8ec7f652007-08-15 14:28:01 +000089
90Exit
Terry Jan Reedybafef5a2014-12-05 02:42:54 -050091 Close all windows and quit IDLE (ask to save unsaved windows).
Georg Brandl8ec7f652007-08-15 14:28:01 +000092
Terry Jan Reedyeb405892014-12-04 00:55:46 -050093Edit menu (Shell and Editor)
94^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Georg Brandl8ec7f652007-08-15 14:28:01 +000095
96Undo
Terry Jan Reedybafef5a2014-12-05 02:42:54 -050097 Undo the last change to the current window. A maximum of 1000 changes may
98 be undone.
Georg Brandl8ec7f652007-08-15 14:28:01 +000099
100Redo
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500101 Redo the last undone change to the current window.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000102
103Cut
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500104 Copy selection into the system-wide clipboard; then delete the selection.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000105
106Copy
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500107 Copy selection into the system-wide clipboard.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000108
109Paste
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500110 Insert contents of the system-wide clipboard into the current window.
111
112The clipboard functions are also available in context menus.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000113
114Select All
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500115 Select the entire contents of the current window.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000116
117Find...
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500118 Open a search dialog with many options
Georg Brandl8ec7f652007-08-15 14:28:01 +0000119
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500120Find Again
121 Repeat the last search, if there is one.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000122
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500123Find Selection
124 Search for the currently selected string, if there is one.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000125
126Find in Files...
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500127 Open a file search dialog. Put results in an new output window.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000128
129Replace...
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500130 Open a search-and-replace dialog.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000131
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500132Go to Line
133 Move cursor to the line number requested and make that line visible.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000134
Terry Jan Reedybafef5a2014-12-05 02:42:54 -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.
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500142
143Show call tip
144 After an unclosed parenthesis for a function, open a small window with
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500145 function parameter hints.
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500146
147Show surrounding parens
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500148 Highlight the surrounding parenthesis.
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500149
150Format menu (Editor window only)
151^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
152
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500153Indent Region
154 Shift selected lines right by the indent width (default 4 spaces).
Georg Brandl8ec7f652007-08-15 14:28:01 +0000155
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500156Dedent Region
157 Shift selected lines left by the indent width (default 4 spaces).
Georg Brandl8ec7f652007-08-15 14:28:01 +0000158
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500159Comment Out Region
160 Insert ## in front of selected lines.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000161
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500162Uncomment Region
163 Remove leading # or ## from selected lines.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000164
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500165Tabify Region
166 Turn *leading* stretches of spaces into tabs. (Note: We recommend using
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500167 4 space blocks to indent Python code.)
Georg Brandl8ec7f652007-08-15 14:28:01 +0000168
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500169Untabify Region
170 Turn *all* tabs into the correct number of spaces.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000171
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500172Toggle Tabs
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500173 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 Brandl8ec7f652007-08-15 14:28:01 +0000178
179Format Paragraph
Terry Jan Reedybafef5a2014-12-05 02:42:54 -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 Brandl8ec7f652007-08-15 14:28:01 +0000183
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500184Strip trailing whitespace
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500185 Remove any space characters after the last non-space character of a line.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000186
187.. index::
Georg Brandl8ec7f652007-08-15 14:28:01 +0000188 single: Run script
189
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500190Run menu (Editor window only)
191^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Georg Brandl8ec7f652007-08-15 14:28:01 +0000192
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500193Python Shell
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500194 Open or wake up the Python Shell window.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000195
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500196Check Module
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500197 Check the syntax of the module currently open in the Editor window. If the
Terry Jan Reedybafef5a2014-12-05 02:42:54 -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 Brandl8ec7f652007-08-15 14:28:01 +0000202
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500203Run Module
204 Do Check Module (above). If no error, restart the shell to clean the
205 environment, then execute the module.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000206
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500207Shell menu (Shell window only)
208^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Ned Deilyc859bd22012-10-20 13:23:25 -0700209
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500210View Last Restart
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500211 Scroll the shell window to the last Shell restart.
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500212
213Restart Shell
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500214 Restart the shell to clean the environment.
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500215
216Debug menu (Shell window only)
217^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Georg Brandl8ec7f652007-08-15 14:28:01 +0000218
Terry Jan Reedybafef5a2014-12-05 02:42:54 -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 Brandl8ec7f652007-08-15 14:28:01 +0000225
226.. index::
Georg Brandl8ec7f652007-08-15 14:28:01 +0000227 single: debugger
Terry Jan Reedybafef5a2014-12-05 02:42:54 -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 Brandl8ec7f652007-08-15 14:28:01 +0000241
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500242Options menu (Shell and Editor)
243^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Georg Brandl8ec7f652007-08-15 14:28:01 +0000244
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500245Configure 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 Reedybafef5a2014-12-05 02:42:54 -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
Ned Deilyb2f949a2015-07-04 15:04:42 -0700251 files in .idlerc. On OS X, open the configuration dialog by selecting
252 Preferences in the application menu.
Ned Deilyc859bd22012-10-20 13:23:25 -0700253
Terry Jan Reedy9e466cf2014-12-04 01:22:41 -0500254Configure Extensions
255 Open a configuration dialog for setting preferences for extensions
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500256 (discussed below). See note above about the location of user settings.
Terry Jan Reedy9e466cf2014-12-04 01:22:41 -0500257
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500258Code Context (toggle)(Editor Window only)
259 Open a pane at the top of the edit window which shows the block context
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500260 of the code which has scrolled above the top of the window.
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500261
Ned Deilyb5daa3d2015-01-17 21:03:41 -0800262Window menu (Shell and Editor)
263^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500264
265Zoom Height
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500266 Toggles the window between normal size and maximum height. The initial size
267 defaults to 40 lines by 80 chars unless changed on the General tab of the
268 Configure IDLE dialog.
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500269
270The rest of this menu lists the names of all open windows; select one to bring
271it to the foreground (deiconifying it if necessary).
272
273Help menu (Shell and Editor)
274^^^^^^^^^^^^^^^^^^^^^^^^^^^^
275
276About IDLE
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500277 Display version, copyright, license, credits, and more.
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500278
279IDLE Help
280 Display a help file for IDLE detailing the menu options, basic editing and
281 navigation, and other tips.
282
283Python Docs
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500284 Access local Python documentation, if installed, or start a web browser
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500285 and open docs.python.org showing the latest Python documentation.
286
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500287Turtle Demo
288 Run the turtledemo module with example python code and turtle drawings.
289
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500290Additional help sources may be added here with the Configure IDLE dialog under
291the General tab.
292
293.. index::
294 single: Cut
295 single: Copy
296 single: Paste
297 single: Set Breakpoint
298 single: Clear Breakpoint
299 single: breakpoints
300
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500301Context Menus
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500302^^^^^^^^^^^^^^^^^^^^^^^^^^
303
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500304Open a context menu by right-clicking in a window (Control-click on OS X).
305Context menus have the standard clipboard functions also on the Edit menu.
Ned Deilyc859bd22012-10-20 13:23:25 -0700306
Andrew Svetlov5018db72012-11-01 22:39:14 +0200307Cut
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500308 Copy selection into the system-wide clipboard; then delete the selection.
Andrew Svetlov5018db72012-11-01 22:39:14 +0200309
310Copy
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500311 Copy selection into the system-wide clipboard.
Andrew Svetlov5018db72012-11-01 22:39:14 +0200312
313Paste
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500314 Insert contents of the system-wide clipboard into the current window.
315
316Editor windows also have breakpoint functions. Lines with a breakpoint set are
317specially marked. Breakpoints only have an effect when running under the
318debugger. Breakpoints for a file are saved in the user's .idlerc directory.
Andrew Svetlov5018db72012-11-01 22:39:14 +0200319
Ned Deilyc859bd22012-10-20 13:23:25 -0700320Set Breakpoint
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500321 Set a breakpoint on the current line.
Ned Deilyc859bd22012-10-20 13:23:25 -0700322
323Clear Breakpoint
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500324 Clear the breakpoint on that line.
Ned Deilyc859bd22012-10-20 13:23:25 -0700325
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500326Shell and Output windows have the following.
Andrew Svetlov5018db72012-11-01 22:39:14 +0200327
Ned Deilyc859bd22012-10-20 13:23:25 -0700328Go to file/line
329 Same as in Debug menu.
330
331
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500332Editing and navigation
333----------------------
334
335In this section, 'C' refers to the Control key on Windows and Unix and
336the Command key on Mac OSX.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000337
338* :kbd:`Backspace` deletes to the left; :kbd:`Del` deletes to the right
339
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500340* :kbd:`C-Backspace` delete word left; :kbd:`C-Del` delete word to the right
341
Georg Brandl8ec7f652007-08-15 14:28:01 +0000342* Arrow keys and :kbd:`Page Up`/:kbd:`Page Down` to move around
343
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500344* :kbd:`C-LeftArrow` and :kbd:`C-RightArrow` moves by words
345
Georg Brandl8ec7f652007-08-15 14:28:01 +0000346* :kbd:`Home`/:kbd:`End` go to begin/end of line
347
348* :kbd:`C-Home`/:kbd:`C-End` go to begin/end of file
349
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500350* Some useful Emacs bindings are inherited from Tcl/Tk:
351
352 * :kbd:`C-a` beginning of line
353
354 * :kbd:`C-e` end of line
355
356 * :kbd:`C-k` kill line (but doesn't put it in clipboard)
357
358 * :kbd:`C-l` center window around the insertion point
359
360 * :kbd:`C-b` go backwards one character without deleting (usually you can
361 also use the cursor key for this)
362
363 * :kbd:`C-f` go forward one character without deleting (usually you can
364 also use the cursor key for this)
365
366 * :kbd:`C-p` go up one line (usually you can also use the cursor key for
367 this)
368
369 * :kbd:`C-d` delete next character
370
371Standard keybindings (like :kbd:`C-c` to copy and :kbd:`C-v` to paste)
372may work. Keybindings are selected in the Configure IDLE dialog.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000373
374
375Automatic indentation
376^^^^^^^^^^^^^^^^^^^^^
377
378After a block-opening statement, the next line is indented by 4 spaces (in the
379Python Shell window by one tab). After certain keywords (break, return etc.)
380the next line is dedented. In leading indentation, :kbd:`Backspace` deletes up
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500381to 4 spaces if they are there. :kbd:`Tab` inserts spaces (in the Python
382Shell window one tab), number depends on Indent width. Currently tabs
383are restricted to four spaces due to Tcl/Tk limitations.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000384
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500385See also the indent/dedent region commands in the edit menu.
386
387Completions
388^^^^^^^^^^^
389
390Completions are supplied for functions, classes, and attributes of classes,
391both built-in and user-defined. Completions are also provided for
392filenames.
393
394The AutoCompleteWindow (ACW) will open after a predefined delay (default is
395two seconds) after a '.' or (in a string) an os.sep is typed. If after one
396of those characters (plus zero or more other characters) a tab is typed
397the ACW will open immediately if a possible continuation is found.
398
399If there is only one possible completion for the characters entered, a
400:kbd:`Tab` will supply that completion without opening the ACW.
401
402'Show Completions' will force open a completions window, by default the
403:kbd:`C-space` will open a completions window. In an empty
404string, this will contain the files in the current directory. On a
405blank line, it will contain the built-in and user-defined functions and
406classes in the current name spaces, plus any modules imported. If some
407characters have been entered, the ACW will attempt to be more specific.
408
409If a string of characters is typed, the ACW selection will jump to the
410entry most closely matching those characters. Entering a :kbd:`tab` will
411cause the longest non-ambiguous match to be entered in the Editor window or
412Shell. Two :kbd:`tab` in a row will supply the current ACW selection, as
413will return or a double click. Cursor keys, Page Up/Down, mouse selection,
414and the scroll wheel all operate on the ACW.
415
416"Hidden" attributes can be accessed by typing the beginning of hidden
417name after a '.', e.g. '_'. This allows access to modules with
418``__all__`` set, or to class-private attributes.
419
420Completions and the 'Expand Word' facility can save a lot of typing!
421
422Completions are currently limited to those in the namespaces. Names in
423an Editor window which are not via ``__main__`` and :data:`sys.modules` will
424not be found. Run the module once with your imports to correct this situation.
425Note that IDLE itself places quite a few modules in sys.modules, so
426much can be found by default, e.g. the re module.
427
428If you don't like the ACW popping up unbidden, simply make the delay
429longer or disable the extension. Or another option is the delay could
430be set to zero. Another alternative to preventing ACW popups is to
431disable the call tips extension.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000432
433Python Shell window
434^^^^^^^^^^^^^^^^^^^
435
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500436* :kbd:`C-c` interrupts executing command
Georg Brandl8ec7f652007-08-15 14:28:01 +0000437
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500438* :kbd:`C-d` sends end-of-file; closes window if typed at a ``>>>`` prompt
Georg Brandl8ec7f652007-08-15 14:28:01 +0000439
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500440* :kbd:`Alt-/` (Expand word) is also useful to reduce typing
Georg Brandl8ec7f652007-08-15 14:28:01 +0000441
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500442 Command history
Georg Brandl8ec7f652007-08-15 14:28:01 +0000443
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500444 * :kbd:`Alt-p` retrieves previous command matching what you have typed. On
445 OS X use :kbd:`C-p`.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000446
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500447 * :kbd:`Alt-n` retrieves next. On OS X use :kbd:`C-n`.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000448
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500449 * :kbd:`Return` while on any previous command retrieves that command
Georg Brandl8ec7f652007-08-15 14:28:01 +0000450
451
452Syntax colors
453-------------
454
455The coloring is applied in a background "thread," so you may occasionally see
456uncolorized text. To change the color scheme, edit the ``[Colors]`` section in
457:file:`config.txt`.
458
459Python syntax colors:
460 Keywords
461 orange
462
Georg Brandlc62ef8b2009-01-03 20:55:06 +0000463 Strings
Georg Brandl8ec7f652007-08-15 14:28:01 +0000464 green
465
466 Comments
467 red
468
469 Definitions
470 blue
471
472Shell colors:
473 Console output
474 brown
475
476 stdout
477 blue
478
479 stderr
480 dark green
481
482 stdin
483 black
484
485
Georg Brandl09827eb2009-03-15 21:51:48 +0000486Startup
487-------
488
489Upon startup with the ``-s`` option, IDLE will execute the file referenced by
490the environment variables :envvar:`IDLESTARTUP` or :envvar:`PYTHONSTARTUP`.
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500491IDLE first checks for ``IDLESTARTUP``; if ``IDLESTARTUP`` is present the file
492referenced is run. If ``IDLESTARTUP`` is not present, IDLE checks for
Georg Brandl09827eb2009-03-15 21:51:48 +0000493``PYTHONSTARTUP``. Files referenced by these environment variables are
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500494convenient places to store functions that are used frequently from the IDLE
Georg Brandl09827eb2009-03-15 21:51:48 +0000495shell, or for executing import statements to import common modules.
496
497In addition, ``Tk`` also loads a startup file if it is present. Note that the
498Tk file is loaded unconditionally. This additional file is ``.Idle.py`` and is
499looked for in the user's home directory. Statements in this file will be
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500500executed in the Tk namespace, so this file is not useful for importing
501functions to be used from IDLE's Python shell.
Georg Brandl09827eb2009-03-15 21:51:48 +0000502
503
Georg Brandl8ec7f652007-08-15 14:28:01 +0000504Command line usage
505^^^^^^^^^^^^^^^^^^
506
507::
508
509 idle.py [-c command] [-d] [-e] [-s] [-t title] [arg] ...
510
511 -c command run this command
512 -d enable debugger
513 -e edit mode; arguments are files to be edited
514 -s run $IDLESTARTUP or $PYTHONSTARTUP first
515 -t title set title of shell window
516
517If there are arguments:
518
Éric Araujoa8132ec2010-12-16 03:53:53 +0000519#. If ``-e`` is used, arguments are files opened for editing and
Georg Brandl8ec7f652007-08-15 14:28:01 +0000520 ``sys.argv`` reflects the arguments passed to IDLE itself.
521
Éric Araujoa8132ec2010-12-16 03:53:53 +0000522#. Otherwise, if ``-c`` is used, all arguments are placed in
Georg Brandl8ec7f652007-08-15 14:28:01 +0000523 ``sys.argv[1:...]``, with ``sys.argv[0]`` set to ``'-c'``.
524
Éric Araujoa8132ec2010-12-16 03:53:53 +0000525#. Otherwise, if neither ``-e`` nor ``-c`` is used, the first
Georg Brandl8ec7f652007-08-15 14:28:01 +0000526 argument is a script which is executed with the remaining arguments in
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500527 ``sys.argv[1:...]`` and ``sys.argv[0]`` set to the script name. If the
528 script name is '-', no script is executed but an interactive Python session
529 is started; the arguments are still available in ``sys.argv``.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000530
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500531Running without a subprocess
532^^^^^^^^^^^^^^^^^^^^^^^^^^^^
533
534If IDLE is started with the -n command line switch it will run in a
535single process and will not create the subprocess which runs the RPC
536Python execution server. This can be useful if Python cannot create
537the subprocess or the RPC socket interface on your platform. However,
538in this mode user code is not isolated from IDLE itself. Also, the
539environment is not restarted when Run/Run Module (F5) is selected. If
540your code has been modified, you must reload() the affected modules and
541re-import any specific items (e.g. from foo import baz) if the changes
542are to take effect. For these reasons, it is preferable to run IDLE
543with the default subprocess if at all possible.
544
545.. deprecated:: 3.4
546
547
Terry Jan Reedy9e466cf2014-12-04 01:22:41 -0500548Help and preferences
549--------------------
550
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500551Additional help sources
Terry Jan Reedy9e466cf2014-12-04 01:22:41 -0500552^^^^^^^^^^^^^^^^^^^^^^^
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500553
554IDLE includes a help menu entry called "Python Docs" that will open the
555extensive sources of help, including tutorials, available at docs.python.org.
556Selected URLs can be added or removed from the help menu at any time using the
557Configure IDLE dialog. See the IDLE help option in the help menu of IDLE for
558more information.
559
560
Terry Jan Reedy9e466cf2014-12-04 01:22:41 -0500561Setting preferences
562^^^^^^^^^^^^^^^^^^^
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500563
564The font preferences, highlighting, keys, and general preferences can be
Terry Jan Reedy9e466cf2014-12-04 01:22:41 -0500565changed via Configure IDLE on the Option menu. Keys can be user defined;
566IDLE ships with four built in key sets. In addition a user can create a
567custom key set in the Configure IDLE dialog under the keys tab.
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500568
569
570Extensions
Terry Jan Reedy9e466cf2014-12-04 01:22:41 -0500571^^^^^^^^^^
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500572
Terry Jan Reedy9e466cf2014-12-04 01:22:41 -0500573IDLE contains an extension facility. Peferences for extensions can be
574changed with Configure Extensions. See the beginning of config-extensions.def
575in the idlelib directory for further information. The default extensions
576are currently:
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500577
578* FormatParagraph
579
580* AutoExpand
581
582* ZoomHeight
583
584* ScriptBinding
585
586* CallTips
587
588* ParenMatch
589
590* AutoComplete
591
592* CodeContext
Georg Brandl8ec7f652007-08-15 14:28:01 +0000593
Terry Jan Reedy9e466cf2014-12-04 01:22:41 -0500594* RstripExtension