blob: 7a5bebd69f8f2d209ffe277730a1d9122ca16c8d [file] [log] [blame]
Georg Brandl116aa622007-08-15 14:28:22 +00001.. _idle:
2
Christian Heimes5b5e81c2007-12-31 16:14:33 +00003IDLE
Georg Brandl116aa622007-08-15 14:28:22 +00004====
5
6.. moduleauthor:: Guido van Rossum <guido@Python.org>
7
Georg Brandl116aa622007-08-15 14:28:22 +00008.. index::
Christian Heimes5b5e81c2007-12-31 16:14:33 +00009 single: IDLE
Georg Brandl116aa622007-08-15 14:28:22 +000010 single: Python Editor
11 single: Integrated Development Environment
12
Georg Brandlac6060c2008-05-17 18:44:45 +000013IDLE is the Python IDE built with the :mod:`tkinter` GUI toolkit.
Georg Brandl116aa622007-08-15 14:28:22 +000014
15IDLE has the following features:
16
Georg Brandlac6060c2008-05-17 18:44:45 +000017* coded in 100% pure Python, using the :mod:`tkinter` GUI toolkit
Georg Brandl116aa622007-08-15 14:28:22 +000018
19* cross-platform: works on Windows and Unix (on Mac OS, there are currently
20 problems with Tcl/Tk)
21
22* multi-window text editor with multiple undo, Python colorizing and many other
23 features, e.g. smart indent and call tips
24
25* Python shell window (a.k.a. interactive interpreter)
26
27* debugger (not complete, but you can set breakpoints, view and step)
28
29
30Menus
31-----
32
33
34File menu
35^^^^^^^^^
36
37New window
38 create a new editing window
39
40Open...
41 open an existing file
42
43Open module...
44 open an existing module (searches sys.path)
45
46Class browser
47 show classes and methods in current file
48
49Path browser
50 show sys.path directories, modules, classes and methods
51
52.. index::
53 single: Class browser
54 single: Path browser
55
56Save
57 save current window to the associated file (unsaved windows have a \* before and
58 after the window title)
59
60Save As...
61 save current window to new file, which becomes the associated file
62
63Save Copy As...
64 save current window to different file without changing the associated file
65
66Close
67 close current window (asks to save if unsaved)
68
69Exit
70 close all windows and quit IDLE (asks to save if unsaved)
71
72
73Edit menu
74^^^^^^^^^
75
76Undo
77 Undo last change to current window (max 1000 changes)
78
79Redo
80 Redo last undone change to current window
81
82Cut
83 Copy selection into system-wide clipboard; then delete selection
84
85Copy
86 Copy selection into system-wide clipboard
87
88Paste
89 Insert system-wide clipboard into window
90
91Select All
92 Select the entire contents of the edit buffer
93
94Find...
95 Open a search dialog box with many options
96
97Find again
98 Repeat last search
99
100Find selection
101 Search for the string in the selection
102
103Find in Files...
104 Open a search dialog box for searching files
105
106Replace...
107 Open a search-and-replace dialog box
108
109Go to line
110 Ask for a line number and show that line
111
112Indent region
113 Shift selected lines right 4 spaces
114
115Dedent region
116 Shift selected lines left 4 spaces
117
118Comment out region
119 Insert ## in front of selected lines
120
121Uncomment region
122 Remove leading # or ## from selected lines
123
124Tabify region
125 Turns *leading* stretches of spaces into tabs
126
127Untabify region
128 Turn *all* tabs into the right number of spaces
129
130Expand word
131 Expand the word you have typed to match another word in the same buffer; repeat
132 to get a different expansion
133
134Format Paragraph
135 Reformat the current blank-line-separated paragraph
136
137Import module
138 Import or reload the current module
139
140Run script
141 Execute the current file in the __main__ namespace
142
143.. index::
144 single: Import module
145 single: Run script
146
147
148Windows menu
149^^^^^^^^^^^^
150
151Zoom Height
152 toggles the window between normal size (24x80) and maximum height.
153
154The rest of this menu lists the names of all open windows; select one to bring
155it to the foreground (deiconifying it if necessary).
156
157
158Debug menu (in the Python Shell window only)
159^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
160
161Go to file/line
162 look around the insert point for a filename and linenumber, open the file, and
163 show the line.
164
165Open stack viewer
166 show the stack traceback of the last exception
167
168Debugger toggle
169 Run commands in the shell under the debugger
170
171JIT Stack viewer toggle
172 Open stack viewer on traceback
173
174.. index::
175 single: stack viewer
176 single: debugger
177
178
179Basic editing and navigation
180----------------------------
181
182* :kbd:`Backspace` deletes to the left; :kbd:`Del` deletes to the right
183
184* Arrow keys and :kbd:`Page Up`/:kbd:`Page Down` to move around
185
186* :kbd:`Home`/:kbd:`End` go to begin/end of line
187
188* :kbd:`C-Home`/:kbd:`C-End` go to begin/end of file
189
190* Some :program:`Emacs` bindings may also work, including :kbd:`C-B`,
191 :kbd:`C-P`, :kbd:`C-A`, :kbd:`C-E`, :kbd:`C-D`, :kbd:`C-L`
192
193
194Automatic indentation
195^^^^^^^^^^^^^^^^^^^^^
196
197After a block-opening statement, the next line is indented by 4 spaces (in the
198Python Shell window by one tab). After certain keywords (break, return etc.)
199the next line is dedented. In leading indentation, :kbd:`Backspace` deletes up
200to 4 spaces if they are there. :kbd:`Tab` inserts 1-4 spaces (in the Python
201Shell window one tab). See also the indent/dedent region commands in the edit
202menu.
203
204
205Python Shell window
206^^^^^^^^^^^^^^^^^^^
207
208* :kbd:`C-C` interrupts executing command
209
210* :kbd:`C-D` sends end-of-file; closes window if typed at a ``>>>`` prompt
211
212* :kbd:`Alt-p` retrieves previous command matching what you have typed
213
214* :kbd:`Alt-n` retrieves next
215
216* :kbd:`Return` while on any previous command retrieves that command
217
218* :kbd:`Alt-/` (Expand word) is also useful here
219
220.. index:: single: indentation
221
222
223Syntax colors
224-------------
225
226The coloring is applied in a background "thread," so you may occasionally see
227uncolorized text. To change the color scheme, edit the ``[Colors]`` section in
228:file:`config.txt`.
229
230Python syntax colors:
231 Keywords
232 orange
233
234 Strings
235 green
236
237 Comments
238 red
239
240 Definitions
241 blue
242
243Shell colors:
244 Console output
245 brown
246
247 stdout
248 blue
249
250 stderr
251 dark green
252
253 stdin
254 black
255
256
257Command line usage
258^^^^^^^^^^^^^^^^^^
259
260::
261
262 idle.py [-c command] [-d] [-e] [-s] [-t title] [arg] ...
263
264 -c command run this command
265 -d enable debugger
266 -e edit mode; arguments are files to be edited
267 -s run $IDLESTARTUP or $PYTHONSTARTUP first
268 -t title set title of shell window
269
270If there are arguments:
271
272#. If :option:`-e` is used, arguments are files opened for editing and
273 ``sys.argv`` reflects the arguments passed to IDLE itself.
274
275#. Otherwise, if :option:`-c` is used, all arguments are placed in
276 ``sys.argv[1:...]``, with ``sys.argv[0]`` set to ``'-c'``.
277
278#. Otherwise, if neither :option:`-e` nor :option:`-c` is used, the first
279 argument is a script which is executed with the remaining arguments in
280 ``sys.argv[1:...]`` and ``sys.argv[0]`` set to the script name. If the script
281 name is '-', no script is executed but an interactive Python session is started;
282 the arguments are still available in ``sys.argv``.
283
284