blob: 95401734984d095989ad169860bad8a0b730bae8 [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
Terry Jan Reedyec4bdac2013-07-01 00:52:18 -040024 New File -- Create a new file editing window
Andrew Svetlov1bd7f022013-01-14 19:27:36 +020025 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
Ned Deilyf1ce6de2015-07-04 15:05:07 -0700132 sources can be specified. On OS X, open the
133 configuration dialog by selecting Preferences
134 in the application menu.
Kurt B. Kaiser39c7b452002-12-11 04:42:39 +0000135
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200136 ---
137 Code Context (toggle) -- Open a pane at the top of the edit window
138 which shows the block context of the section
139 of code which is scrolling off the top or the
140 window. This is not present in the Shell
141 window only the Editor window.
Kurt B. Kaiser39c7b452002-12-11 04:42:39 +0000142
Ned Deilyccb416f2015-01-17 21:06:27 -0800143Window Menu (Shell and Editor):
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200144
145 Zoom Height -- Toggles the window between normal size (40x80 initial
146 setting) and maximum height. The initial size is in the Configure
147 IDLE dialog under the general tab.
148 ---
149 The rest of this menu lists the names of all open windows;
150 select one to bring it to the foreground (deiconifying it if
151 necessary).
David Scherer7aced172000-08-15 01:13:23 +0000152
Kurt B. Kaiser39c7b452002-12-11 04:42:39 +0000153Help Menu:
154
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200155 About IDLE -- Version, copyright, license, credits
156 ---
157 IDLE Help -- Display this file which is a help file for IDLE
158 detailing the menu options, basic editing and navigation,
159 and other tips.
160 Python Docs -- Access local Python documentation, if
161 installed. Or will start a web browser and open
162 docs.python.org showing the latest Python documentation.
163 ---
164 Additional help sources may be added here with the Configure IDLE
165 dialog under the General tab.
Kurt B. Kaiser39c7b452002-12-11 04:42:39 +0000166
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200167Editor context menu (Right-click / Control-click on OS X in Edit window):
Ned Deily2778d0d2012-10-20 13:25:34 -0700168
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200169 Cut -- Copy a selection into system-wide clipboard,
Andrew Svetlovd1837672012-11-01 22:41:19 +0200170 then delete the selection
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200171 Copy -- Copy selection into system-wide clipboard
172 Paste -- Insert system-wide clipboard into window
173 Set Breakpoint -- Sets a breakpoint. Breakpoints are only enabled
174 when the debugger is open.
175 Clear Breakpoint -- Clears the breakpoint on that line
Ned Deily2778d0d2012-10-20 13:25:34 -0700176
Andrew Svetlovd1837672012-11-01 22:41:19 +0200177Shell context menu (Right-click / Control-click on OS X in Shell window):
Ned Deily2778d0d2012-10-20 13:25:34 -0700178
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200179 Cut -- Copy a selection into system-wide clipboard,
Andrew Svetlovd1837672012-11-01 22:41:19 +0200180 then delete the selection
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200181 Copy -- Copy selection into system-wide clipboard
182 Paste -- Insert system-wide clipboard into window
183 ---
184 Go to file/line -- Same as in Debug menu
Ned Deily2778d0d2012-10-20 13:25:34 -0700185
Kurt B. Kaiser6fa09112003-01-14 22:06:11 +0000186
187** TIPS **
188==========
189
190Additional Help Sources:
191
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200192 Windows users can Google on zopeshelf.chm to access Zope help files in
193 the Windows help format. The Additional Help Sources feature of the
194 configuration GUI supports .chm, along with any other filetypes
195 supported by your browser. Supply a Menu Item title, and enter the
196 location in the Help File Path slot of the New Help Source dialog. Use
197 http:// and/or www. to identify external URLs, or download the file and
198 browse for its path on your machine using the Browse button.
Kurt B. Kaiser6fa09112003-01-14 22:06:11 +0000199
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200200 All users can access the extensive sources of help, including
201 tutorials, available at docs.python.org. Selected URLs can be added
202 or removed from the Help menu at any time using Configure IDLE.
David Scherer7aced172000-08-15 01:13:23 +0000203
204Basic editing and navigation:
205
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200206 Backspace deletes char to the left; DEL deletes char to the right.
207 Control-backspace deletes word left, Control-DEL deletes word right.
208 Arrow keys and Page Up/Down move around.
209 Control-left/right Arrow moves by words in a strange but useful way.
210 Home/End go to begin/end of line.
211 Control-Home/End go to begin/end of file.
212 Some useful Emacs bindings are inherited from Tcl/Tk:
213 Control-a beginning of line
214 Control-e end of line
215 Control-k kill line (but doesn't put it in clipboard)
216 Control-l center window around the insertion point
217 Standard keybindings (like Control-c to copy and Control-v to
218 paste) may work. Keybindings are selected in the Configure IDLE
219 dialog.
David Scherer7aced172000-08-15 01:13:23 +0000220
221Automatic indentation:
222
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200223 After a block-opening statement, the next line is indented by 4 spaces
224 (in the Python Shell window by one tab). After certain keywords
225 (break, return etc.) the next line is dedented. In leading
226 indentation, Backspace deletes up to 4 spaces if they are there. Tab
227 inserts spaces (in the Python Shell window one tab), number depends on
228 Indent Width. Currently tabs are restricted to four spaces due
229 to Tcl/Tk limitations.
Kurt B. Kaisereb9637e2003-01-26 04:17:16 +0000230
Kurt B. Kaiser39c7b452002-12-11 04:42:39 +0000231 See also the indent/dedent region commands in the edit menu.
David Scherer7aced172000-08-15 01:13:23 +0000232
Thomas Wouterscf297e42007-02-23 15:07:44 +0000233Completions:
234
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200235 Completions are supplied for functions, classes, and attributes of
236 classes, both built-in and user-defined. Completions are also provided
237 for filenames.
Thomas Wouterscf297e42007-02-23 15:07:44 +0000238
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200239 The AutoCompleteWindow (ACW) will open after a predefined delay
240 (default is two seconds) after a '.' or (in a string) an os.sep is
241 typed. If after one of those characters (plus zero or more other
242 characters) a tab is typed the ACW will open immediately if a possible
243 continuation is found.
Thomas Wouterscf297e42007-02-23 15:07:44 +0000244
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200245 If there is only one possible completion for the characters entered, a
246 tab will supply that completion without opening the ACW.
Thomas Wouterscf297e42007-02-23 15:07:44 +0000247
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200248 'Show Completions' will force open a completions window, by default the
249 Control-space keys will open a completions window. In an empty
250 string, this will contain the files in the current directory. On a
251 blank line, it will contain the built-in and user-defined functions and
252 classes in the current name spaces, plus any modules imported. If some
253 characters have been entered, the ACW will attempt to be more specific.
Thomas Wouterscf297e42007-02-23 15:07:44 +0000254
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200255 If string of characters is typed, the ACW selection will jump to the
256 entry most closely matching those characters. Entering a tab will cause
257 the longest non-ambiguous match to be entered in the Edit window or
258 Shell. Two tabs in a row will supply the current ACW selection, as
259 will return or a double click. Cursor keys, Page Up/Down, mouse
260 selection, and the scroll wheel all operate on the ACW.
Thomas Wouterscf297e42007-02-23 15:07:44 +0000261
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200262 "Hidden" attributes can be accessed by typing the beginning of hidden
263 name after a '.', e.g. '_'. This allows access to modules with
264 '__all__' set, or to class-private attributes.
Thomas Wouterscf297e42007-02-23 15:07:44 +0000265
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200266 Completions and the 'Expand Word' facility can save a lot of typing!
Thomas Wouterscf297e42007-02-23 15:07:44 +0000267
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200268 Completions are currently limited to those in the namespaces. Names in
269 an Editor window which are not via __main__ or sys.modules will not be
270 found. Run the module once with your imports to correct this
271 situation. Note that IDLE itself places quite a few modules in
272 sys.modules, so much can be found by default, e.g. the re module.
Thomas Wouterscf297e42007-02-23 15:07:44 +0000273
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200274 If you don't like the ACW popping up unbidden, simply make the delay
275 longer or disable the extension. Or another option is the delay could
276 be set to zero. Another alternative to preventing ACW popups is to
277 disable the call tips extension.
Thomas Wouterscf297e42007-02-23 15:07:44 +0000278
David Scherer7aced172000-08-15 01:13:23 +0000279Python Shell window:
280
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200281 Control-c interrupts executing command.
Roger Serwy22b9e652013-04-17 00:27:31 -0500282 Control-d sends end-of-file; closes window if typed at >>> prompt.
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200283 Alt-/ expand word is also useful to reduce typing.
David Scherer7aced172000-08-15 01:13:23 +0000284
285 Command history:
286
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200287 Alt-p retrieves previous command matching what you have typed. On OS X
288 use Control-p.
289 Alt-n retrieves next. On OS X use Control-n.
290 Return while cursor is on a previous command retrieves that command.
David Scherer7aced172000-08-15 01:13:23 +0000291
Kurt B. Kaisereb9637e2003-01-26 04:17:16 +0000292 Syntax colors:
David Scherer7aced172000-08-15 01:13:23 +0000293
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200294 The coloring is applied in a background "thread", so you may
295 occasionally see uncolorized text. To change the color
296 scheme, use the Configure IDLE / Highlighting dialog.
David Scherer7aced172000-08-15 01:13:23 +0000297
Kurt B. Kaiser39c7b452002-12-11 04:42:39 +0000298 Python default syntax colors:
David Scherer7aced172000-08-15 01:13:23 +0000299
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200300 Keywords orange
301 Builtins royal purple
302 Strings green
303 Comments red
304 Definitions blue
David Scherer7aced172000-08-15 01:13:23 +0000305
Kurt B. Kaiser39c7b452002-12-11 04:42:39 +0000306 Shell default colors:
David Scherer7aced172000-08-15 01:13:23 +0000307
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200308 Console output brown
309 stdout blue
310 stderr red
311 stdin black
David Scherer7aced172000-08-15 01:13:23 +0000312
313Other preferences:
314
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200315 The font preferences, highlighting, keys, and general preferences can
316 be changed via the Configure IDLE menu option. Be sure to note that
317 keys can be user defined, IDLE ships with four built in key sets. In
318 addition a user can create a custom key set in the Configure IDLE
319 dialog under the keys tab.
David Scherer7aced172000-08-15 01:13:23 +0000320
321Command line usage:
Thomas Wouterscf297e42007-02-23 15:07:44 +0000322
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200323 Enter idle -h at the command prompt to get a usage message.
Kurt B. Kaiser8f570a72003-05-15 18:52:51 +0000324
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200325 idle.py [-c command] [-d] [-e] [-s] [-t title] [arg] ...
Kurt B. Kaiser8f570a72003-05-15 18:52:51 +0000326
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200327 -c command run this command
328 -d enable debugger
329 -e edit mode; arguments are files to be edited
330 -s run $IDLESTARTUP or $PYTHONSTARTUP first
331 -t title set title of shell window
332
333 If there are arguments:
334 1. If -e is used, arguments are files opened for editing and sys.argv
335 reflects the arguments passed to IDLE itself.
336 2. Otherwise, if -c is used, all arguments are placed in
337 sys.argv[1:...], with sys.argv[0] set to -c.
338 3. Otherwise, if neither -e nor -c is used, the first argument is a
339 script which is executed with the remaining arguments in
340 sys.argv[1:...] and sys.argv[0] set to the script name. If the
341 script name is -, no script is executed but an interactive Python
342 session is started; the arguments are still available in sys.argv.
343
R David Murraya707f292013-04-13 15:29:22 -0400344Running without a subprocess: (DEPRECATED in Python 3.4 see Issue 16123)
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200345
346 If IDLE is started with the -n command line switch it will run in a
347 single process and will not create the subprocess which runs the RPC
348 Python execution server. This can be useful if Python cannot create
349 the subprocess or the RPC socket interface on your platform. However,
350 in this mode user code is not isolated from IDLE itself. Also, the
351 environment is not restarted when Run/Run Module (F5) is selected. If
352 your code has been modified, you must reload() the affected modules and
353 re-import any specific items (e.g. from foo import baz) if the changes
354 are to take effect. For these reasons, it is preferable to run IDLE
355 with the default subprocess if at all possible.
Thomas Wouterscf297e42007-02-23 15:07:44 +0000356
357Extensions:
358
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200359 IDLE contains an extension facility. See the beginning of
360 config-extensions.def in the idlelib directory for further information.
361 The default extensions are currently:
Thomas Wouterscf297e42007-02-23 15:07:44 +0000362
Andrew Svetlov1bd7f022013-01-14 19:27:36 +0200363 FormatParagraph
364 AutoExpand
365 ZoomHeight
366 ScriptBinding
367 CallTips
368 ParenMatch
369 AutoComplete
370 CodeContext