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