blob: 24914e46975989ce0e0dcf22802f7f0a2dcf6732 [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.
Georg Brandl8ec7f652007-08-15 14:28:01 +000040
Terry Jan Reedyeb405892014-12-04 00:55:46 -050041File menu (Shell and Editor)
42^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Georg Brandl8ec7f652007-08-15 14:28:01 +000043
Terry Jan Reedybafef5a2014-12-05 02:42:54 -050044New File
45 Create a new file editing window.
Georg Brandl8ec7f652007-08-15 14:28:01 +000046
47Open...
Terry Jan Reedybafef5a2014-12-05 02:42:54 -050048 Open an existing file with an Open dialog.
Georg Brandl8ec7f652007-08-15 14:28:01 +000049
Terry Jan Reedyeb405892014-12-04 00:55:46 -050050Recent Files
Terry Jan Reedybafef5a2014-12-05 02:42:54 -050051 Open a list of recent files. Click one to open it.
52
53Open Module...
54 Open an existing module (searches sys.path).
Georg Brandl8ec7f652007-08-15 14:28:01 +000055
56.. index::
57 single: Class browser
58 single: Path browser
59
Terry Jan Reedybafef5a2014-12-05 02:42:54 -050060Class Browser
61 Show functions, classes, and methods in the current Editor file in a
62 tree structure. In the shell, open a module first.
Terry Jan Reedyeb405892014-12-04 00:55:46 -050063
Terry Jan Reedybafef5a2014-12-05 02:42:54 -050064Path Browser
65 Show sys.path directories, modules, functions, classes and methods in a
66 tree structure.
Terry Jan Reedyeb405892014-12-04 00:55:46 -050067
Georg Brandl8ec7f652007-08-15 14:28:01 +000068Save
Terry Jan Reedybafef5a2014-12-05 02:42:54 -050069 Save the current window to the associated file, if there is one. Windows
70 that have been changed since being opened or last saved have a \* before
71 and after the window title. If there is no associated file,
72 do Save As instead.
Georg Brandl8ec7f652007-08-15 14:28:01 +000073
74Save As...
Terry Jan Reedybafef5a2014-12-05 02:42:54 -050075 Save the current window with a Save As dialog. The file saved becomes the
76 new associated file for the window.
Georg Brandl8ec7f652007-08-15 14:28:01 +000077
78Save Copy As...
Terry Jan Reedybafef5a2014-12-05 02:42:54 -050079 Save the current window to different file without changing the associated
80 file.
Terry Jan Reedyeb405892014-12-04 00:55:46 -050081
82Print Window
Terry Jan Reedybafef5a2014-12-05 02:42:54 -050083 Print the current window to the default printer.
Georg Brandl8ec7f652007-08-15 14:28:01 +000084
85Close
Terry Jan Reedybafef5a2014-12-05 02:42:54 -050086 Close the current window (ask to save if unsaved).
Georg Brandl8ec7f652007-08-15 14:28:01 +000087
88Exit
Terry Jan Reedybafef5a2014-12-05 02:42:54 -050089 Close all windows and quit IDLE (ask to save unsaved windows).
Georg Brandl8ec7f652007-08-15 14:28:01 +000090
Terry Jan Reedyeb405892014-12-04 00:55:46 -050091Edit menu (Shell and Editor)
92^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Georg Brandl8ec7f652007-08-15 14:28:01 +000093
94Undo
Terry Jan Reedybafef5a2014-12-05 02:42:54 -050095 Undo the last change to the current window. A maximum of 1000 changes may
96 be undone.
Georg Brandl8ec7f652007-08-15 14:28:01 +000097
98Redo
Terry Jan Reedybafef5a2014-12-05 02:42:54 -050099 Redo the last undone change to the current window.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000100
101Cut
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500102 Copy selection into the system-wide clipboard; then delete the selection.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000103
104Copy
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500105 Copy selection into the system-wide clipboard.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000106
107Paste
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500108 Insert contents of the system-wide clipboard into the current window.
109
110The clipboard functions are also available in context menus.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000111
112Select All
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500113 Select the entire contents of the current window.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000114
115Find...
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500116 Open a search dialog with many options
Georg Brandl8ec7f652007-08-15 14:28:01 +0000117
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500118Find Again
119 Repeat the last search, if there is one.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000120
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500121Find Selection
122 Search for the currently selected string, if there is one.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000123
124Find in Files...
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500125 Open a file search dialog. Put results in an new output window.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000126
127Replace...
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500128 Open a search-and-replace dialog.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000129
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500130Go to Line
131 Move cursor to the line number requested and make that line visible.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000132
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500133Show Completions
134 Open a scrollable list allowing selection of keywords and attributes. See
135 Completions in the Tips sections below.
136
137Expand Word
138 Expand a prefix you have typed to match a full word in the same window;
139 repeat to get a different expansion.
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500140
141Show call tip
142 After an unclosed parenthesis for a function, open a small window with
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500143 function parameter hints.
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500144
145Show surrounding parens
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500146 Highlight the surrounding parenthesis.
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500147
148Format menu (Editor window only)
149^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
150
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500151Indent Region
152 Shift selected lines right by the indent width (default 4 spaces).
Georg Brandl8ec7f652007-08-15 14:28:01 +0000153
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500154Dedent Region
155 Shift selected lines left by the indent width (default 4 spaces).
Georg Brandl8ec7f652007-08-15 14:28:01 +0000156
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500157Comment Out Region
158 Insert ## in front of selected lines.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000159
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500160Uncomment Region
161 Remove leading # or ## from selected lines.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000162
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500163Tabify Region
164 Turn *leading* stretches of spaces into tabs. (Note: We recommend using
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500165 4 space blocks to indent Python code.)
Georg Brandl8ec7f652007-08-15 14:28:01 +0000166
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500167Untabify Region
168 Turn *all* tabs into the correct number of spaces.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000169
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500170Toggle Tabs
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500171 Open a dialog to switch between indenting with spaces and tabs.
172
173New Indent Width
174 Open a dialog to change indent width. The accepted default by the Python
175 community is 4 spaces.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000176
177Format Paragraph
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500178 Reformat the current blank-line-delimited paragraph in comment block or
179 multiline string or selected line in a string. All lines in the
180 paragraph will be formatted to less than N columns, where N defaults to 72.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000181
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500182Strip trailing whitespace
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500183 Remove any space characters after the last non-space character of a line.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000184
185.. index::
Georg Brandl8ec7f652007-08-15 14:28:01 +0000186 single: Run script
187
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500188Run menu (Editor window only)
189^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Georg Brandl8ec7f652007-08-15 14:28:01 +0000190
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500191Python Shell
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500192 Open or wake up the Python Shell window.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000193
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500194Check Module
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500195 Check the syntax of the module currently open in the Editor window. If the
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500196 module has not been saved IDLE will either prompt the user to save or
197 autosave, as selected in the General tab of the Idle Settings dialog. If
198 there is a syntax error, the approximate location is indicated in the
199 Editor window.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000200
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500201Run Module
202 Do Check Module (above). If no error, restart the shell to clean the
203 environment, then execute the module.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000204
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500205Shell menu (Shell window only)
206^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Ned Deilyc859bd22012-10-20 13:23:25 -0700207
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500208View Last Restart
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500209 Scroll the shell window to the last Shell restart.
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500210
211Restart Shell
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500212 Restart the shell to clean the environment.
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500213
214Debug menu (Shell window only)
215^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Georg Brandl8ec7f652007-08-15 14:28:01 +0000216
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500217Go to File/Line
218 Look on the current line. with the cursor, and the line above for a filename
219 and line number. If found, open the file if not already open, and show the
220 line. Use this to view source lines referenced in an exception traceback
221 and lines found by Find in Files. Also available in the context menu of
222 the Shell window and Output windows.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000223
224.. index::
Georg Brandl8ec7f652007-08-15 14:28:01 +0000225 single: debugger
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500226 single: stack viewer
227
228Debugger (toggle)
229 When actived, code entered in the Shell or run from an Editor will run
230 under the debugger. In the Editor, breakpoints can be set with the context
231 menu. This feature is still incomplete and somewhat experimental.
232
233Stack Viewer
234 Show the stack traceback of the last exception in a tree widget, with
235 access to locals and globals.
236
237Auto-open Stack Viewer
238 Toggle automatically opening the stack viewer on an unhandled exception.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000239
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500240Options menu (Shell and Editor)
241^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Georg Brandl8ec7f652007-08-15 14:28:01 +0000242
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500243Configure IDLE
244 Open a configuration dialog. Fonts, indentation, keybindings, and color
245 themes may be altered. Startup Preferences may be set, and additional
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500246 help sources can be specified. Non-default user setting are saved in a
247 .idlerc directory in the user's home directory. Problems caused by bad user
248 configuration files are solved by editing or deleting one or more of the
Ned Deilyb2f949a2015-07-04 15:04:42 -0700249 files in .idlerc. On OS X, open the configuration dialog by selecting
250 Preferences in the application menu.
Ned Deilyc859bd22012-10-20 13:23:25 -0700251
Terry Jan Reedy9e466cf2014-12-04 01:22:41 -0500252Configure Extensions
253 Open a configuration dialog for setting preferences for extensions
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500254 (discussed below). See note above about the location of user settings.
Terry Jan Reedy9e466cf2014-12-04 01:22:41 -0500255
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500256Code Context (toggle)(Editor Window only)
257 Open a pane at the top of the edit window which shows the block context
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500258 of the code which has scrolled above the top of the window.
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500259
Ned Deilyb5daa3d2015-01-17 21:03:41 -0800260Window menu (Shell and Editor)
261^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500262
263Zoom Height
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500264 Toggles the window between normal size and maximum height. The initial size
265 defaults to 40 lines by 80 chars unless changed on the General tab of the
266 Configure IDLE dialog.
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500267
268The rest of this menu lists the names of all open windows; select one to bring
269it to the foreground (deiconifying it if necessary).
270
271Help menu (Shell and Editor)
272^^^^^^^^^^^^^^^^^^^^^^^^^^^^
273
274About IDLE
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500275 Display version, copyright, license, credits, and more.
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500276
277IDLE Help
278 Display a help file for IDLE detailing the menu options, basic editing and
279 navigation, and other tips.
280
281Python Docs
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500282 Access local Python documentation, if installed, or start a web browser
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500283 and open docs.python.org showing the latest Python documentation.
284
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500285Turtle Demo
286 Run the turtledemo module with example python code and turtle drawings.
287
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500288Additional help sources may be added here with the Configure IDLE dialog under
289the General tab.
290
291.. index::
292 single: Cut
293 single: Copy
294 single: Paste
295 single: Set Breakpoint
296 single: Clear Breakpoint
297 single: breakpoints
298
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500299Context Menus
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500300^^^^^^^^^^^^^^^^^^^^^^^^^^
301
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500302Open a context menu by right-clicking in a window (Control-click on OS X).
303Context menus have the standard clipboard functions also on the Edit menu.
Ned Deilyc859bd22012-10-20 13:23:25 -0700304
Andrew Svetlov5018db72012-11-01 22:39:14 +0200305Cut
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500306 Copy selection into the system-wide clipboard; then delete the selection.
Andrew Svetlov5018db72012-11-01 22:39:14 +0200307
308Copy
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500309 Copy selection into the system-wide clipboard.
Andrew Svetlov5018db72012-11-01 22:39:14 +0200310
311Paste
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500312 Insert contents of the system-wide clipboard into the current window.
313
314Editor windows also have breakpoint functions. Lines with a breakpoint set are
315specially marked. Breakpoints only have an effect when running under the
316debugger. Breakpoints for a file are saved in the user's .idlerc directory.
Andrew Svetlov5018db72012-11-01 22:39:14 +0200317
Ned Deilyc859bd22012-10-20 13:23:25 -0700318Set Breakpoint
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500319 Set a breakpoint on the current line.
Ned Deilyc859bd22012-10-20 13:23:25 -0700320
321Clear Breakpoint
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500322 Clear the breakpoint on that line.
Ned Deilyc859bd22012-10-20 13:23:25 -0700323
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500324Shell and Output windows have the following.
Andrew Svetlov5018db72012-11-01 22:39:14 +0200325
Ned Deilyc859bd22012-10-20 13:23:25 -0700326Go to file/line
327 Same as in Debug menu.
328
329
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500330Editing and navigation
331----------------------
332
Serhiy Storchaka9b2e37f2015-09-12 17:47:12 +0300333In this section, 'C' refers to the :kbd:`Control` key on Windows and Unix and
334the :kbd:`Command` key on Mac OSX.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000335
336* :kbd:`Backspace` deletes to the left; :kbd:`Del` deletes to the right
337
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500338* :kbd:`C-Backspace` delete word left; :kbd:`C-Del` delete word to the right
339
Georg Brandl8ec7f652007-08-15 14:28:01 +0000340* Arrow keys and :kbd:`Page Up`/:kbd:`Page Down` to move around
341
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500342* :kbd:`C-LeftArrow` and :kbd:`C-RightArrow` moves by words
343
Georg Brandl8ec7f652007-08-15 14:28:01 +0000344* :kbd:`Home`/:kbd:`End` go to begin/end of line
345
346* :kbd:`C-Home`/:kbd:`C-End` go to begin/end of file
347
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500348* Some useful Emacs bindings are inherited from Tcl/Tk:
349
350 * :kbd:`C-a` beginning of line
351
352 * :kbd:`C-e` end of line
353
354 * :kbd:`C-k` kill line (but doesn't put it in clipboard)
355
356 * :kbd:`C-l` center window around the insertion point
357
358 * :kbd:`C-b` go backwards one character without deleting (usually you can
359 also use the cursor key for this)
360
361 * :kbd:`C-f` go forward one character without deleting (usually you can
362 also use the cursor key for this)
363
364 * :kbd:`C-p` go up one line (usually you can also use the cursor key for
365 this)
366
367 * :kbd:`C-d` delete next character
368
369Standard keybindings (like :kbd:`C-c` to copy and :kbd:`C-v` to paste)
370may work. Keybindings are selected in the Configure IDLE dialog.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000371
372
373Automatic indentation
374^^^^^^^^^^^^^^^^^^^^^
375
376After a block-opening statement, the next line is indented by 4 spaces (in the
377Python Shell window by one tab). After certain keywords (break, return etc.)
378the next line is dedented. In leading indentation, :kbd:`Backspace` deletes up
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500379to 4 spaces if they are there. :kbd:`Tab` inserts spaces (in the Python
380Shell window one tab), number depends on Indent width. Currently tabs
381are restricted to four spaces due to Tcl/Tk limitations.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000382
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500383See also the indent/dedent region commands in the edit menu.
384
385Completions
386^^^^^^^^^^^
387
388Completions are supplied for functions, classes, and attributes of classes,
389both built-in and user-defined. Completions are also provided for
390filenames.
391
392The AutoCompleteWindow (ACW) will open after a predefined delay (default is
393two seconds) after a '.' or (in a string) an os.sep is typed. If after one
394of those characters (plus zero or more other characters) a tab is typed
395the ACW will open immediately if a possible continuation is found.
396
397If there is only one possible completion for the characters entered, a
398:kbd:`Tab` will supply that completion without opening the ACW.
399
400'Show Completions' will force open a completions window, by default the
401:kbd:`C-space` will open a completions window. In an empty
402string, this will contain the files in the current directory. On a
403blank line, it will contain the built-in and user-defined functions and
404classes in the current name spaces, plus any modules imported. If some
405characters have been entered, the ACW will attempt to be more specific.
406
407If a string of characters is typed, the ACW selection will jump to the
408entry most closely matching those characters. Entering a :kbd:`tab` will
409cause the longest non-ambiguous match to be entered in the Editor window or
410Shell. Two :kbd:`tab` in a row will supply the current ACW selection, as
411will return or a double click. Cursor keys, Page Up/Down, mouse selection,
412and the scroll wheel all operate on the ACW.
413
414"Hidden" attributes can be accessed by typing the beginning of hidden
415name after a '.', e.g. '_'. This allows access to modules with
416``__all__`` set, or to class-private attributes.
417
418Completions and the 'Expand Word' facility can save a lot of typing!
419
420Completions are currently limited to those in the namespaces. Names in
421an Editor window which are not via ``__main__`` and :data:`sys.modules` will
422not be found. Run the module once with your imports to correct this situation.
423Note that IDLE itself places quite a few modules in sys.modules, so
424much can be found by default, e.g. the re module.
425
426If you don't like the ACW popping up unbidden, simply make the delay
427longer or disable the extension. Or another option is the delay could
428be set to zero. Another alternative to preventing ACW popups is to
429disable the call tips extension.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000430
431Python Shell window
432^^^^^^^^^^^^^^^^^^^
433
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500434* :kbd:`C-c` interrupts executing command
Georg Brandl8ec7f652007-08-15 14:28:01 +0000435
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500436* :kbd:`C-d` sends end-of-file; closes window if typed at a ``>>>`` prompt
Georg Brandl8ec7f652007-08-15 14:28:01 +0000437
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500438* :kbd:`Alt-/` (Expand word) is also useful to reduce typing
Georg Brandl8ec7f652007-08-15 14:28:01 +0000439
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500440 Command history
Georg Brandl8ec7f652007-08-15 14:28:01 +0000441
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500442 * :kbd:`Alt-p` retrieves previous command matching what you have typed. On
443 OS X use :kbd:`C-p`.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000444
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500445 * :kbd:`Alt-n` retrieves next. On OS X use :kbd:`C-n`.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000446
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500447 * :kbd:`Return` while on any previous command retrieves that command
Georg Brandl8ec7f652007-08-15 14:28:01 +0000448
449
450Syntax colors
451-------------
452
453The coloring is applied in a background "thread," so you may occasionally see
454uncolorized text. To change the color scheme, edit the ``[Colors]`` section in
455:file:`config.txt`.
456
457Python syntax colors:
458 Keywords
459 orange
460
Georg Brandlc62ef8b2009-01-03 20:55:06 +0000461 Strings
Georg Brandl8ec7f652007-08-15 14:28:01 +0000462 green
463
464 Comments
465 red
466
467 Definitions
468 blue
469
470Shell colors:
471 Console output
472 brown
473
474 stdout
475 blue
476
477 stderr
478 dark green
479
480 stdin
481 black
482
483
Georg Brandl09827eb2009-03-15 21:51:48 +0000484Startup
485-------
486
487Upon startup with the ``-s`` option, IDLE will execute the file referenced by
488the environment variables :envvar:`IDLESTARTUP` or :envvar:`PYTHONSTARTUP`.
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500489IDLE first checks for ``IDLESTARTUP``; if ``IDLESTARTUP`` is present the file
490referenced is run. If ``IDLESTARTUP`` is not present, IDLE checks for
Georg Brandl09827eb2009-03-15 21:51:48 +0000491``PYTHONSTARTUP``. Files referenced by these environment variables are
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500492convenient places to store functions that are used frequently from the IDLE
Georg Brandl09827eb2009-03-15 21:51:48 +0000493shell, or for executing import statements to import common modules.
494
495In addition, ``Tk`` also loads a startup file if it is present. Note that the
496Tk file is loaded unconditionally. This additional file is ``.Idle.py`` and is
497looked for in the user's home directory. Statements in this file will be
Terry Jan Reedybafef5a2014-12-05 02:42:54 -0500498executed in the Tk namespace, so this file is not useful for importing
499functions to be used from IDLE's Python shell.
Georg Brandl09827eb2009-03-15 21:51:48 +0000500
501
Georg Brandl8ec7f652007-08-15 14:28:01 +0000502Command line usage
503^^^^^^^^^^^^^^^^^^
504
505::
506
Terry Jan Reedyc7025c62015-09-23 03:52:18 -0400507 idle.py [-c command] [-d] [-e] [-h] [-i] [-r file] [-s] [-t title] [-] [arg] ...
Georg Brandl8ec7f652007-08-15 14:28:01 +0000508
Terry Jan Reedyc7025c62015-09-23 03:52:18 -0400509 -c command run command in the shell window
510 -d enable debugger and open shell window
511 -e open editor window
512 -h print help message with legal combinatios and exit
513 -i open shell window
514 -r file run file in shell window
515 -s run $IDLESTARTUP or $PYTHONSTARTUP first, in shell window
Georg Brandl8ec7f652007-08-15 14:28:01 +0000516 -t title set title of shell window
Terry Jan Reedyc7025c62015-09-23 03:52:18 -0400517 - run stdin in shell (- must be last option before args)
Georg Brandl8ec7f652007-08-15 14:28:01 +0000518
519If there are arguments:
520
Terry Jan Reedyc7025c62015-09-23 03:52:18 -0400521* If ``-``, ``-c``, or ``r`` is used, all arguments are placed in
522 ``sys.argv[1:...]`` and ``sys.argv[0]`` is set to ``''``, ``'-c'``,
523 or ``'-r'``. No editor window is opened, even if that is the default
524 set in the Options dialog.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000525
Terry Jan Reedyc7025c62015-09-23 03:52:18 -0400526* Otherwise, arguments are files opened for editing and
527 ``sys.argv`` reflects the arguments passed to IDLE itself.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000528
Georg Brandl8ec7f652007-08-15 14:28:01 +0000529
Terry Jan Reedyeb405892014-12-04 00:55:46 -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
546
Terry Jan Reedy9e466cf2014-12-04 01:22:41 -0500547Help and preferences
548--------------------
549
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500550Additional help sources
Terry Jan Reedy9e466cf2014-12-04 01:22:41 -0500551^^^^^^^^^^^^^^^^^^^^^^^
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500552
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 Reedy9e466cf2014-12-04 01:22:41 -0500560Setting preferences
561^^^^^^^^^^^^^^^^^^^
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500562
563The font preferences, highlighting, keys, and general preferences can be
Terry Jan Reedy9e466cf2014-12-04 01:22:41 -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.
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500567
568
569Extensions
Terry Jan Reedy9e466cf2014-12-04 01:22:41 -0500570^^^^^^^^^^
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500571
Terry Jan Reedy9e466cf2014-12-04 01:22:41 -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:
Terry Jan Reedyeb405892014-12-04 00:55:46 -0500576
577* FormatParagraph
578
579* AutoExpand
580
581* ZoomHeight
582
583* ScriptBinding
584
585* CallTips
586
587* ParenMatch
588
589* AutoComplete
590
591* CodeContext
Georg Brandl8ec7f652007-08-15 14:28:01 +0000592
Terry Jan Reedy9e466cf2014-12-04 01:22:41 -0500593* RstripExtension