6 .. moduleauthor:: Guido van Rossum <guido@Python.org>
11 single: Integrated Development Environment
13 IDLE is the Python IDE built with the :mod:`tkinter` GUI toolkit.
15 IDLE has the following features:
17 * coded in 100% pure Python, using the :mod:`tkinter` GUI toolkit
19 * cross-platform: works on Windows and Unix
21 * multi-window text editor with multiple undo, Python colorizing and many other
22 features, e.g. smart indent and call tips
24 * Python shell window (a.k.a. interactive interpreter)
26 * debugger (not complete, but you can set breakpoints, view and step)
37 create a new editing window
43 open an existing module (searches sys.path)
46 show classes and methods in current file
49 show sys.path directories, modules, classes and methods
56 save current window to the associated file (unsaved windows have a \* before and
57 after the window title)
60 save current window to new file, which becomes the associated file
63 save current window to different file without changing the associated file
66 close current window (asks to save if unsaved)
69 close all windows and quit IDLE (asks to save if unsaved)
76 Undo last change to current window (max 1000 changes)
79 Redo last undone change to current window
82 Copy selection into system-wide clipboard; then delete selection
85 Copy selection into system-wide clipboard
88 Insert system-wide clipboard into window
91 Select the entire contents of the edit buffer
94 Open a search dialog box with many options
100 Search for the string in the selection
103 Open a search dialog box for searching files
106 Open a search-and-replace dialog box
109 Ask for a line number and show that line
112 Shift selected lines right 4 spaces
115 Shift selected lines left 4 spaces
118 Insert ## in front of selected lines
121 Remove leading # or ## from selected lines
124 Turns *leading* stretches of spaces into tabs
127 Turn *all* tabs into the right number of spaces
130 Expand the word you have typed to match another word in the same buffer; repeat
131 to get a different expansion
134 Reformat the current blank-line-separated paragraph
137 Import or reload the current module
140 Execute the current file in the __main__ namespace
143 single: Import module
151 toggles the window between normal size (24x80) and maximum height.
153 The rest of this menu lists the names of all open windows; select one to bring
154 it to the foreground (deiconifying it if necessary).
157 Debug menu (in the Python Shell window only)
158 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
161 look around the insert point for a filename and linenumber, open the file, and
165 show the stack traceback of the last exception
168 Run commands in the shell under the debugger
170 JIT Stack viewer toggle
171 Open stack viewer on traceback
178 Basic editing and navigation
179 ----------------------------
181 * :kbd:`Backspace` deletes to the left; :kbd:`Del` deletes to the right
183 * Arrow keys and :kbd:`Page Up`/:kbd:`Page Down` to move around
185 * :kbd:`Home`/:kbd:`End` go to begin/end of line
187 * :kbd:`C-Home`/:kbd:`C-End` go to begin/end of file
189 * Some :program:`Emacs` bindings may also work, including :kbd:`C-B`,
190 :kbd:`C-P`, :kbd:`C-A`, :kbd:`C-E`, :kbd:`C-D`, :kbd:`C-L`
193 Automatic indentation
194 ^^^^^^^^^^^^^^^^^^^^^
196 After a block-opening statement, the next line is indented by 4 spaces (in the
197 Python Shell window by one tab). After certain keywords (break, return etc.)
198 the next line is dedented. In leading indentation, :kbd:`Backspace` deletes up
199 to 4 spaces if they are there. :kbd:`Tab` inserts 1-4 spaces (in the Python
200 Shell window one tab). See also the indent/dedent region commands in the edit
207 * :kbd:`C-C` interrupts executing command
209 * :kbd:`C-D` sends end-of-file; closes window if typed at a ``>>>`` prompt
211 * :kbd:`Alt-p` retrieves previous command matching what you have typed
213 * :kbd:`Alt-n` retrieves next
215 * :kbd:`Return` while on any previous command retrieves that command
217 * :kbd:`Alt-/` (Expand word) is also useful here
219 .. index:: single: indentation
225 The coloring is applied in a background "thread," so you may occasionally see
226 uncolorized text. To change the color scheme, edit the ``[Colors]`` section in
229 Python syntax colors:
259 Upon startup with the ``-s`` option, IDLE will execute the file referenced by
260 the environment variables :envvar:`IDLESTARTUP` or :envvar:`PYTHONSTARTUP`.
261 Idle first checks for ``IDLESTARTUP``; if ``IDLESTARTUP`` is present the file
262 referenced is run. If ``IDLESTARTUP`` is not present, Idle checks for
263 ``PYTHONSTARTUP``. Files referenced by these environment variables are
264 convenient places to store functions that are used frequently from the Idle
265 shell, or for executing import statements to import common modules.
267 In addition, ``Tk`` also loads a startup file if it is present. Note that the
268 Tk file is loaded unconditionally. This additional file is ``.Idle.py`` and is
269 looked for in the user's home directory. Statements in this file will be
270 executed in the Tk namespace, so this file is not useful for importing functions
271 to be used from Idle's Python shell.
279 idle.py [-c command] [-d] [-e] [-s] [-t title] [arg] ...
281 -c command run this command
283 -e edit mode; arguments are files to be edited
284 -s run $IDLESTARTUP or $PYTHONSTARTUP first
285 -t title set title of shell window
287 If there are arguments:
289 #. If :option:`-e` is used, arguments are files opened for editing and
290 ``sys.argv`` reflects the arguments passed to IDLE itself.
292 #. Otherwise, if :option:`-c` is used, all arguments are placed in
293 ``sys.argv[1:...]``, with ``sys.argv[0]`` set to ``'-c'``.
295 #. Otherwise, if neither :option:`-e` nor :option:`-c` is used, the first
296 argument is a script which is executed with the remaining arguments in
297 ``sys.argv[1:...]`` and ``sys.argv[0]`` set to the script name. If the script
298 name is '-', no script is executed but an interactive Python session is started;
299 the arguments are still available in ``sys.argv``.