blob: c4e1231f1a71f13e80efc42e95259d7fd41b0cb3 [file] [log] [blame]
Kurt B. Kaiser6fa09112003-01-14 22:06:11 +00001[See the end of this file for ** TIPS ** on using IDLE !!]
David Scherer7aced172000-08-15 01:13:23 +00002
Andrew Svetlov1bd7f022013-01-14 19:27:36 +02003IDLE is the Python IDE built with the tkinter GUI toolkit.
David Scherer7aced172000-08-15 01:13:23 +00004
Andrew Svetlov1bd7f022013-01-14 19:27:36 +02005IDLE has the following features:
6-coded in 100% pure Python, using the tkinter GUI toolkit
7-cross-platform: works on Windows, Unix, and OS X
8-multi-window text editor with multiple undo, Python colorizing, smart indent,
9call tips, and many other features
10-Python shell window (a.k.a interactive interpreter)
11-debugger (not complete, but you can set breakpoints, view and step)
David Scherer7aced172000-08-15 01:13:23 +000012
Andrew Svetlov1bd7f022013-01-14 19:27:36 +020013Menus:
14
15IDLE has two window types the Shell window and the Editor window. It is
16possible to have multiple editor windows simultaneously. IDLE's
17menus dynamically change based on which window is currently selected. Each menu
18documented below indicates which window type it is associated with. Click on
19the dotted line at the top of a menu to "tear it off": a separate window
20containing the menu is created (for Unix and Windows only).
21
22File Menu (Shell and Editor):
23
24 New Window -- Create a new editing window
25 Open... -- Open an existing file
26 Open Module... -- Open an existing module (searches sys.path)
27 Recent Files... -- Open a list of recent files
28 Class Browser -- Show classes and methods in current file
29 Path Browser -- Show sys.path directories, modules, classes,
Kurt B. Kaisereb9637e2003-01-26 04:17:16 +000030 and methods
Andrew Svetlov1bd7f022013-01-14 19:27:36 +020031 ---
32 Save -- Save current window to the associated file (unsaved
33 windows have a * before and after the window title)
David Scherer7aced172000-08-15 01:13:23 +000034
Andrew Svetlov1bd7f022013-01-14 19:27:36 +020035 Save As... -- Save current window to new file, which becomes
36 the associated file
37 Save Copy As... -- Save current window to different file
38 without changing the associated file
39 ---
40 Print Window -- Print the current window
41 ---
42 Close -- Close current window (asks to save if unsaved)
43 Exit -- Close all windows, quit (asks to save if unsaved)
David Scherer7aced172000-08-15 01:13:23 +000044
Andrew Svetlov1bd7f022013-01-14 19:27:36 +020045Edit Menu (Shell and Editor):
David Scherer7aced172000-08-15 01:13:23 +000046
Andrew Svetlov1bd7f022013-01-14 19:27:36 +020047 Undo -- Undo last change to current window
48 (a maximum of 1000 changes may be undone)
49 Redo -- Redo last undone change to current window
50 ---
51 Cut -- Copy a selection into system-wide clipboard,
Kurt B. Kaisereb9637e2003-01-26 04:17:16 +000052 then delete the selection
Andrew Svetlov1bd7f022013-01-14 19:27:36 +020053 Copy -- Copy selection into system-wide clipboard
54 Paste -- Insert system-wide clipboard into window
55 Select All -- Select the entire contents of the edit buffer
56 ---
57 Find... -- Open a search dialog box with many options
58 Find Again -- Repeat last search
59 Find Selection -- Search for the string in the selection
60 Find in Files... -- Open a search dialog box for searching files
61 Replace... -- Open a search-and-replace dialog box
62 Go to Line -- Ask for a line number and show that line
63 Expand Word -- Expand the word you have typed to match another
64 word in the same buffer; repeat to get a
Kurt B. Kaisereb9637e2003-01-26 04:17:16 +000065 different expansion
Andrew Svetlov1bd7f022013-01-14 19:27:36 +020066 Show Calltip -- After an unclosed parenthesis for a function, open
67 a small window with function parameter hints
68 Show Parens -- Highlight the surrounding parenthesis
69 Show Completions -- Open a scroll window allowing selection keywords
70 and attributes. (see '*TIPS*', below)
Kurt B. Kaiser39c7b452002-12-11 04:42:39 +000071
Andrew Svetlov1bd7f022013-01-14 19:27:36 +020072Format Menu (Editor window only):
Kurt B. Kaiser39c7b452002-12-11 04:42:39 +000073
Andrew Svetlov1bd7f022013-01-14 19:27:36 +020074 Indent Region -- Shift selected lines right by the indent width
75 (default 4 spaces)
76 Dedent Region -- Shift selected lines left by the indent width
77 (default 4 spaces)
78 Comment Out Region -- Insert ## in front of selected lines
79 Uncomment Region -- Remove leading # or ## from selected lines
80 Tabify Region -- Turns *leading* stretches of spaces into tabs.
81 (Note: We recommend using 4 space blocks to indent Python code.)
82 Untabify Region -- Turn *all* tabs into the corrent number of spaces
83 Toggle tabs -- Open a dialog to switch between indenting with
84 spaces and tabs.
85 New Indent Width... -- Open a dialog to change indent width. The
86 accepted default by the Python community is 4
87 spaces.
88 Format Paragraph -- Reformat the current blank-line-separated
89 paragraph. All lines in the paragraph will be
90 formatted to less than 80 columns.
91 ---
92 Strip trailing whitespace -- Removed any space characters after the end
93 of the last non-space character
Kurt B. Kaiser39c7b452002-12-11 04:42:39 +000094
Andrew Svetlov1bd7f022013-01-14 19:27:36 +020095Run Menu (Editor window only):
Kurt B. Kaiser39c7b452002-12-11 04:42:39 +000096
Andrew Svetlov1bd7f022013-01-14 19:27:36 +020097 Python Shell -- Open or wake up the Python shell window
98 ---
99 Check Module -- Check the syntax of the module currently open in the
100 Editor window. If the module has not been saved IDLE
101 will prompt the user to save the code.
102 Run Module -- Restart the shell to clean the environment, then
103 execute the currently open module. If the module has
104 not been saved IDLE will prompt the user to save the
105 code.
David Scherer7aced172000-08-15 01:13:23 +0000106
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200107Shell Menu (Shell window only):
Kurt B. Kaiser1061e722003-01-04 01:43:53 +0000108
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200109 View Last Restart -- Scroll the shell window to the last Shell restart
110 Restart Shell -- Restart the shell to clean the environment
Kurt B. Kaisereb9637e2003-01-26 04:17:16 +0000111
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200112Debug Menu (Shell window only):
Kurt B. Kaisereb9637e2003-01-26 04:17:16 +0000113
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200114 Go to File/Line -- Look around the insert point for a filename
115 and line number, open the file, and show the line.
116 Useful to view the source lines referenced in an
117 exception traceback. Available in the context
118 menu of the Shell window.
119 Debugger (toggle) -- This feature is not complete and considered
120 experimental. Run commands in the shell under the
121 debugger.
122 Stack Viewer -- Show the stack traceback of the last exception
123 Auto-open Stack Viewer (toggle) -- Toggle automatically opening the
124 stack viewer on unhandled
125 exception
Kurt B. Kaiser1061e722003-01-04 01:43:53 +0000126
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200127Options Menu (Shell and Editor):
David Scherer7aced172000-08-15 01:13:23 +0000128
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200129 Configure IDLE -- Open a configuration dialog. Fonts, indentation,
Kurt B. Kaisereb9637e2003-01-26 04:17:16 +0000130 keybindings, and color themes may be altered.
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200131 Startup Preferences may be set, and additional Help
132 sources can be specified.
Kurt B. Kaiser39c7b452002-12-11 04:42:39 +0000133
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200134 ---
135 Code Context (toggle) -- Open a pane at the top of the edit window
136 which shows the block context of the section
137 of code which is scrolling off the top or the
138 window. This is not present in the Shell
139 window only the Editor window.
Kurt B. Kaiser39c7b452002-12-11 04:42:39 +0000140
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200141Windows Menu (Shell and Editor):
142
143 Zoom Height -- Toggles the window between normal size (40x80 initial
144 setting) and maximum height. The initial size is in the Configure
145 IDLE dialog under the general tab.
146 ---
147 The rest of this menu lists the names of all open windows;
148 select one to bring it to the foreground (deiconifying it if
149 necessary).
David Scherer7aced172000-08-15 01:13:23 +0000150
Kurt B. Kaiser39c7b452002-12-11 04:42:39 +0000151Help Menu:
152
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200153 About IDLE -- Version, copyright, license, credits
154 ---
155 IDLE Help -- Display this file which is a help file for IDLE
156 detailing the menu options, basic editing and navigation,
157 and other tips.
158 Python Docs -- Access local Python documentation, if
159 installed. Or will start a web browser and open
160 docs.python.org showing the latest Python documentation.
161 ---
162 Additional help sources may be added here with the Configure IDLE
163 dialog under the General tab.
Kurt B. Kaiser39c7b452002-12-11 04:42:39 +0000164
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200165Editor context menu (Right-click / Control-click on OS X in Edit window):
Ned Deily2778d0d2012-10-20 13:25:34 -0700166
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200167 Cut -- Copy a selection into system-wide clipboard,
Andrew Svetlovd1837672012-11-01 22:41:19 +0200168 then delete the selection
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200169 Copy -- Copy selection into system-wide clipboard
170 Paste -- Insert system-wide clipboard into window
171 Set Breakpoint -- Sets a breakpoint. Breakpoints are only enabled
172 when the debugger is open.
173 Clear Breakpoint -- Clears the breakpoint on that line
Ned Deily2778d0d2012-10-20 13:25:34 -0700174
Andrew Svetlovd1837672012-11-01 22:41:19 +0200175Shell context menu (Right-click / Control-click on OS X in Shell window):
Ned Deily2778d0d2012-10-20 13:25:34 -0700176
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200177 Cut -- Copy a selection into system-wide clipboard,
Andrew Svetlovd1837672012-11-01 22:41:19 +0200178 then delete the selection
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200179 Copy -- Copy selection into system-wide clipboard
180 Paste -- Insert system-wide clipboard into window
181 ---
182 Go to file/line -- Same as in Debug menu
Ned Deily2778d0d2012-10-20 13:25:34 -0700183
Kurt B. Kaiser6fa09112003-01-14 22:06:11 +0000184
185** TIPS **
186==========
187
188Additional Help Sources:
189
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200190 Windows users can Google on zopeshelf.chm to access Zope help files in
191 the Windows help format. The Additional Help Sources feature of the
192 configuration GUI supports .chm, along with any other filetypes
193 supported by your browser. Supply a Menu Item title, and enter the
194 location in the Help File Path slot of the New Help Source dialog. Use
195 http:// and/or www. to identify external URLs, or download the file and
196 browse for its path on your machine using the Browse button.
Kurt B. Kaiser6fa09112003-01-14 22:06:11 +0000197
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200198 All users can access the extensive sources of help, including
199 tutorials, available at docs.python.org. Selected URLs can be added
200 or removed from the Help menu at any time using Configure IDLE.
David Scherer7aced172000-08-15 01:13:23 +0000201
202Basic editing and navigation:
203
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200204 Backspace deletes char to the left; DEL deletes char to the right.
205 Control-backspace deletes word left, Control-DEL deletes word right.
206 Arrow keys and Page Up/Down move around.
207 Control-left/right Arrow moves by words in a strange but useful way.
208 Home/End go to begin/end of line.
209 Control-Home/End go to begin/end of file.
210 Some useful Emacs bindings are inherited from Tcl/Tk:
211 Control-a beginning of line
212 Control-e end of line
213 Control-k kill line (but doesn't put it in clipboard)
214 Control-l center window around the insertion point
215 Standard keybindings (like Control-c to copy and Control-v to
216 paste) may work. Keybindings are selected in the Configure IDLE
217 dialog.
David Scherer7aced172000-08-15 01:13:23 +0000218
219Automatic indentation:
220
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200221 After a block-opening statement, the next line is indented by 4 spaces
222 (in the Python Shell window by one tab). After certain keywords
223 (break, return etc.) the next line is dedented. In leading
224 indentation, Backspace deletes up to 4 spaces if they are there. Tab
225 inserts spaces (in the Python Shell window one tab), number depends on
226 Indent Width. Currently tabs are restricted to four spaces due
227 to Tcl/Tk limitations.
Kurt B. Kaisereb9637e2003-01-26 04:17:16 +0000228
Kurt B. Kaiser39c7b452002-12-11 04:42:39 +0000229 See also the indent/dedent region commands in the edit menu.
David Scherer7aced172000-08-15 01:13:23 +0000230
Thomas Wouterscf297e42007-02-23 15:07:44 +0000231Completions:
232
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200233 Completions are supplied for functions, classes, and attributes of
234 classes, both built-in and user-defined. Completions are also provided
235 for filenames.
Thomas Wouterscf297e42007-02-23 15:07:44 +0000236
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200237 The AutoCompleteWindow (ACW) will open after a predefined delay
238 (default is two seconds) after a '.' or (in a string) an os.sep is
239 typed. If after one of those characters (plus zero or more other
240 characters) a tab is typed the ACW will open immediately if a possible
241 continuation is found.
Thomas Wouterscf297e42007-02-23 15:07:44 +0000242
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200243 If there is only one possible completion for the characters entered, a
244 tab will supply that completion without opening the ACW.
Thomas Wouterscf297e42007-02-23 15:07:44 +0000245
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200246 'Show Completions' will force open a completions window, by default the
247 Control-space keys will open a completions window. In an empty
248 string, this will contain the files in the current directory. On a
249 blank line, it will contain the built-in and user-defined functions and
250 classes in the current name spaces, plus any modules imported. If some
251 characters have been entered, the ACW will attempt to be more specific.
Thomas Wouterscf297e42007-02-23 15:07:44 +0000252
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200253 If string of characters is typed, the ACW selection will jump to the
254 entry most closely matching those characters. Entering a tab will cause
255 the longest non-ambiguous match to be entered in the Edit window or
256 Shell. Two tabs in a row will supply the current ACW selection, as
257 will return or a double click. Cursor keys, Page Up/Down, mouse
258 selection, and the scroll wheel all operate on the ACW.
Thomas Wouterscf297e42007-02-23 15:07:44 +0000259
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200260 "Hidden" attributes can be accessed by typing the beginning of hidden
261 name after a '.', e.g. '_'. This allows access to modules with
262 '__all__' set, or to class-private attributes.
Thomas Wouterscf297e42007-02-23 15:07:44 +0000263
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200264 Completions and the 'Expand Word' facility can save a lot of typing!
Thomas Wouterscf297e42007-02-23 15:07:44 +0000265
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200266 Completions are currently limited to those in the namespaces. Names in
267 an Editor window which are not via __main__ or sys.modules will not be
268 found. Run the module once with your imports to correct this
269 situation. Note that IDLE itself places quite a few modules in
270 sys.modules, so much can be found by default, e.g. the re module.
Thomas Wouterscf297e42007-02-23 15:07:44 +0000271
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200272 If you don't like the ACW popping up unbidden, simply make the delay
273 longer or disable the extension. Or another option is the delay could
274 be set to zero. Another alternative to preventing ACW popups is to
275 disable the call tips extension.
Thomas Wouterscf297e42007-02-23 15:07:44 +0000276
David Scherer7aced172000-08-15 01:13:23 +0000277Python Shell window:
278
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200279 Control-c interrupts executing command.
280 Control-d sends end-of-file; closes window if typed at >>> prompt
281 (this is Control-z on Windows).
282 Alt-/ expand word is also useful to reduce typing.
David Scherer7aced172000-08-15 01:13:23 +0000283
284 Command history:
285
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200286 Alt-p retrieves previous command matching what you have typed. On OS X
287 use Control-p.
288 Alt-n retrieves next. On OS X use Control-n.
289 Return while cursor is on a previous command retrieves that command.
David Scherer7aced172000-08-15 01:13:23 +0000290
Kurt B. Kaisereb9637e2003-01-26 04:17:16 +0000291 Syntax colors:
David Scherer7aced172000-08-15 01:13:23 +0000292
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200293 The coloring is applied in a background "thread", so you may
294 occasionally see uncolorized text. To change the color
295 scheme, use the Configure IDLE / Highlighting dialog.
David Scherer7aced172000-08-15 01:13:23 +0000296
Kurt B. Kaiser39c7b452002-12-11 04:42:39 +0000297 Python default syntax colors:
David Scherer7aced172000-08-15 01:13:23 +0000298
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200299 Keywords orange
300 Builtins royal purple
301 Strings green
302 Comments red
303 Definitions blue
David Scherer7aced172000-08-15 01:13:23 +0000304
Kurt B. Kaiser39c7b452002-12-11 04:42:39 +0000305 Shell default colors:
David Scherer7aced172000-08-15 01:13:23 +0000306
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200307 Console output brown
308 stdout blue
309 stderr red
310 stdin black
David Scherer7aced172000-08-15 01:13:23 +0000311
312Other preferences:
313
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200314 The font preferences, highlighting, keys, and general preferences can
315 be changed via the Configure IDLE menu option. Be sure to note that
316 keys can be user defined, IDLE ships with four built in key sets. In
317 addition a user can create a custom key set in the Configure IDLE
318 dialog under the keys tab.
David Scherer7aced172000-08-15 01:13:23 +0000319
320Command line usage:
Thomas Wouterscf297e42007-02-23 15:07:44 +0000321
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200322 Enter idle -h at the command prompt to get a usage message.
Kurt B. Kaiser8f570a72003-05-15 18:52:51 +0000323
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200324 idle.py [-c command] [-d] [-e] [-s] [-t title] [arg] ...
Kurt B. Kaiser8f570a72003-05-15 18:52:51 +0000325
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200326 -c command run this command
327 -d enable debugger
328 -e edit mode; arguments are files to be edited
329 -s run $IDLESTARTUP or $PYTHONSTARTUP first
330 -t title set title of shell window
331
332 If there are arguments:
333 1. If -e is used, arguments are files opened for editing and sys.argv
334 reflects the arguments passed to IDLE itself.
335 2. Otherwise, if -c is used, all arguments are placed in
336 sys.argv[1:...], with sys.argv[0] set to -c.
337 3. Otherwise, if neither -e nor -c is used, the first argument is a
338 script which is executed with the remaining arguments in
339 sys.argv[1:...] and sys.argv[0] set to the script name. If the
340 script name is -, no script is executed but an interactive Python
341 session is started; the arguments are still available in sys.argv.
342
343Running without a subprocess: (DEPRECATED in Python 3.5 see Issue 16123)
344
345 If IDLE is started with the -n command line switch it will run in a
346 single process and will not create the subprocess which runs the RPC
347 Python execution server. This can be useful if Python cannot create
348 the subprocess or the RPC socket interface on your platform. However,
349 in this mode user code is not isolated from IDLE itself. Also, the
350 environment is not restarted when Run/Run Module (F5) is selected. If
351 your code has been modified, you must reload() the affected modules and
352 re-import any specific items (e.g. from foo import baz) if the changes
353 are to take effect. For these reasons, it is preferable to run IDLE
354 with the default subprocess if at all possible.
Thomas Wouterscf297e42007-02-23 15:07:44 +0000355
356Extensions:
357
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200358 IDLE contains an extension facility. See the beginning of
359 config-extensions.def in the idlelib directory for further information.
360 The default extensions are currently:
Thomas Wouterscf297e42007-02-23 15:07:44 +0000361
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200362 FormatParagraph
363 AutoExpand
364 ZoomHeight
365 ScriptBinding
366 CallTips
367 ParenMatch
368 AutoComplete
369 CodeContext