Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 1 | .. _idle: |
| 2 | |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 3 | IDLE |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 4 | ==== |
| 5 | |
| 6 | .. moduleauthor:: Guido van Rossum <guido@Python.org> |
| 7 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 8 | .. index:: |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 9 | single: IDLE |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 10 | single: Python Editor |
| 11 | single: Integrated Development Environment |
| 12 | |
Georg Brandl | ac6060c | 2008-05-17 18:44:45 +0000 | [diff] [blame] | 13 | IDLE is the Python IDE built with the :mod:`tkinter` GUI toolkit. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 14 | |
| 15 | IDLE has the following features: |
| 16 | |
Georg Brandl | ac6060c | 2008-05-17 18:44:45 +0000 | [diff] [blame] | 17 | * coded in 100% pure Python, using the :mod:`tkinter` GUI toolkit |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 18 | |
Georg Brandl | c575c90 | 2008-09-13 17:46:05 +0000 | [diff] [blame] | 19 | * cross-platform: works on Windows and Unix |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 20 | |
| 21 | * multi-window text editor with multiple undo, Python colorizing and many other |
| 22 | features, e.g. smart indent and call tips |
| 23 | |
| 24 | * Python shell window (a.k.a. interactive interpreter) |
| 25 | |
| 26 | * debugger (not complete, but you can set breakpoints, view and step) |
| 27 | |
| 28 | |
| 29 | Menus |
| 30 | ----- |
| 31 | |
| 32 | |
| 33 | File menu |
| 34 | ^^^^^^^^^ |
| 35 | |
Terry Jan Reedy | 8a0b775 | 2013-07-01 00:42:52 -0400 | [diff] [blame^] | 36 | New file |
| 37 | create a new file editing window |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 38 | |
| 39 | Open... |
| 40 | open an existing file |
| 41 | |
| 42 | Open module... |
| 43 | open an existing module (searches sys.path) |
| 44 | |
| 45 | Class browser |
| 46 | show classes and methods in current file |
| 47 | |
| 48 | Path browser |
| 49 | show sys.path directories, modules, classes and methods |
| 50 | |
| 51 | .. index:: |
| 52 | single: Class browser |
| 53 | single: Path browser |
| 54 | |
| 55 | Save |
| 56 | save current window to the associated file (unsaved windows have a \* before and |
| 57 | after the window title) |
| 58 | |
| 59 | Save As... |
| 60 | save current window to new file, which becomes the associated file |
| 61 | |
| 62 | Save Copy As... |
| 63 | save current window to different file without changing the associated file |
| 64 | |
| 65 | Close |
| 66 | close current window (asks to save if unsaved) |
| 67 | |
| 68 | Exit |
| 69 | close all windows and quit IDLE (asks to save if unsaved) |
| 70 | |
| 71 | |
| 72 | Edit menu |
| 73 | ^^^^^^^^^ |
| 74 | |
| 75 | Undo |
| 76 | Undo last change to current window (max 1000 changes) |
| 77 | |
| 78 | Redo |
| 79 | Redo last undone change to current window |
| 80 | |
| 81 | Cut |
| 82 | Copy selection into system-wide clipboard; then delete selection |
| 83 | |
| 84 | Copy |
| 85 | Copy selection into system-wide clipboard |
| 86 | |
| 87 | Paste |
| 88 | Insert system-wide clipboard into window |
| 89 | |
| 90 | Select All |
| 91 | Select the entire contents of the edit buffer |
| 92 | |
| 93 | Find... |
| 94 | Open a search dialog box with many options |
| 95 | |
| 96 | Find again |
| 97 | Repeat last search |
| 98 | |
| 99 | Find selection |
| 100 | Search for the string in the selection |
| 101 | |
| 102 | Find in Files... |
| 103 | Open a search dialog box for searching files |
| 104 | |
| 105 | Replace... |
| 106 | Open a search-and-replace dialog box |
| 107 | |
| 108 | Go to line |
| 109 | Ask for a line number and show that line |
| 110 | |
| 111 | Indent region |
| 112 | Shift selected lines right 4 spaces |
| 113 | |
| 114 | Dedent region |
| 115 | Shift selected lines left 4 spaces |
| 116 | |
| 117 | Comment out region |
| 118 | Insert ## in front of selected lines |
| 119 | |
| 120 | Uncomment region |
| 121 | Remove leading # or ## from selected lines |
| 122 | |
| 123 | Tabify region |
| 124 | Turns *leading* stretches of spaces into tabs |
| 125 | |
| 126 | Untabify region |
| 127 | Turn *all* tabs into the right number of spaces |
| 128 | |
| 129 | Expand word |
| 130 | Expand the word you have typed to match another word in the same buffer; repeat |
| 131 | to get a different expansion |
| 132 | |
| 133 | Format Paragraph |
| 134 | Reformat the current blank-line-separated paragraph |
| 135 | |
| 136 | Import module |
| 137 | Import or reload the current module |
| 138 | |
| 139 | Run script |
| 140 | Execute the current file in the __main__ namespace |
| 141 | |
| 142 | .. index:: |
| 143 | single: Import module |
| 144 | single: Run script |
| 145 | |
| 146 | |
| 147 | Windows menu |
| 148 | ^^^^^^^^^^^^ |
| 149 | |
| 150 | Zoom Height |
| 151 | toggles the window between normal size (24x80) and maximum height. |
| 152 | |
| 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). |
| 155 | |
| 156 | |
Ned Deily | 2778d0d | 2012-10-20 13:25:34 -0700 | [diff] [blame] | 157 | Debug menu |
| 158 | ^^^^^^^^^^ |
| 159 | |
| 160 | * in the Python Shell window only |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 161 | |
| 162 | Go to file/line |
Ned Deily | 2778d0d | 2012-10-20 13:25:34 -0700 | [diff] [blame] | 163 | Look around the insert point for a filename and line number, open the file, |
| 164 | and show the line. Useful to view the source lines referenced in an |
| 165 | exception traceback. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 166 | |
Ned Deily | 2778d0d | 2012-10-20 13:25:34 -0700 | [diff] [blame] | 167 | Debugger |
| 168 | Run commands in the shell under the debugger. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 169 | |
Ned Deily | 2778d0d | 2012-10-20 13:25:34 -0700 | [diff] [blame] | 170 | Stack viewer |
| 171 | Show the stack traceback of the last exception. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 172 | |
Ned Deily | 2778d0d | 2012-10-20 13:25:34 -0700 | [diff] [blame] | 173 | Auto-open Stack Viewer |
| 174 | Open stack viewer on traceback. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 175 | |
| 176 | .. index:: |
| 177 | single: stack viewer |
| 178 | single: debugger |
| 179 | |
| 180 | |
Ned Deily | 2778d0d | 2012-10-20 13:25:34 -0700 | [diff] [blame] | 181 | Edit context menu |
| 182 | ^^^^^^^^^^^^^^^^^ |
| 183 | |
| 184 | * Right-click in Edit window (Control-click on OS X) |
| 185 | |
Andrew Svetlov | d183767 | 2012-11-01 22:41:19 +0200 | [diff] [blame] | 186 | Cut |
| 187 | Copy selection into system-wide clipboard; then delete selection |
| 188 | |
| 189 | Copy |
| 190 | Copy selection into system-wide clipboard |
| 191 | |
| 192 | Paste |
| 193 | Insert system-wide clipboard into window |
| 194 | |
Ned Deily | 2778d0d | 2012-10-20 13:25:34 -0700 | [diff] [blame] | 195 | Set Breakpoint |
| 196 | Sets a breakpoint. Breakpoints are only enabled when the debugger is open. |
| 197 | |
| 198 | Clear Breakpoint |
| 199 | Clears the breakpoint on that line. |
| 200 | |
| 201 | .. index:: |
Andrew Svetlov | d183767 | 2012-11-01 22:41:19 +0200 | [diff] [blame] | 202 | single: Cut |
| 203 | single: Copy |
| 204 | single: Paste |
Ned Deily | 2778d0d | 2012-10-20 13:25:34 -0700 | [diff] [blame] | 205 | single: Set Breakpoint |
| 206 | single: Clear Breakpoint |
| 207 | single: breakpoints |
| 208 | |
| 209 | |
| 210 | Shell context menu |
| 211 | ^^^^^^^^^^^^^^^^^^ |
| 212 | |
| 213 | * Right-click in Python Shell window (Control-click on OS X) |
| 214 | |
Andrew Svetlov | d183767 | 2012-11-01 22:41:19 +0200 | [diff] [blame] | 215 | Cut |
| 216 | Copy selection into system-wide clipboard; then delete selection |
| 217 | |
| 218 | Copy |
| 219 | Copy selection into system-wide clipboard |
| 220 | |
| 221 | Paste |
| 222 | Insert system-wide clipboard into window |
| 223 | |
Ned Deily | 2778d0d | 2012-10-20 13:25:34 -0700 | [diff] [blame] | 224 | Go to file/line |
| 225 | Same as in Debug menu. |
| 226 | |
| 227 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 228 | Basic editing and navigation |
| 229 | ---------------------------- |
| 230 | |
| 231 | * :kbd:`Backspace` deletes to the left; :kbd:`Del` deletes to the right |
| 232 | |
| 233 | * Arrow keys and :kbd:`Page Up`/:kbd:`Page Down` to move around |
| 234 | |
| 235 | * :kbd:`Home`/:kbd:`End` go to begin/end of line |
| 236 | |
| 237 | * :kbd:`C-Home`/:kbd:`C-End` go to begin/end of file |
| 238 | |
| 239 | * Some :program:`Emacs` bindings may also work, including :kbd:`C-B`, |
| 240 | :kbd:`C-P`, :kbd:`C-A`, :kbd:`C-E`, :kbd:`C-D`, :kbd:`C-L` |
| 241 | |
| 242 | |
| 243 | Automatic indentation |
| 244 | ^^^^^^^^^^^^^^^^^^^^^ |
| 245 | |
| 246 | After a block-opening statement, the next line is indented by 4 spaces (in the |
| 247 | Python Shell window by one tab). After certain keywords (break, return etc.) |
| 248 | the next line is dedented. In leading indentation, :kbd:`Backspace` deletes up |
| 249 | to 4 spaces if they are there. :kbd:`Tab` inserts 1-4 spaces (in the Python |
| 250 | Shell window one tab). See also the indent/dedent region commands in the edit |
| 251 | menu. |
| 252 | |
| 253 | |
| 254 | Python Shell window |
| 255 | ^^^^^^^^^^^^^^^^^^^ |
| 256 | |
| 257 | * :kbd:`C-C` interrupts executing command |
| 258 | |
| 259 | * :kbd:`C-D` sends end-of-file; closes window if typed at a ``>>>`` prompt |
| 260 | |
| 261 | * :kbd:`Alt-p` retrieves previous command matching what you have typed |
| 262 | |
| 263 | * :kbd:`Alt-n` retrieves next |
| 264 | |
| 265 | * :kbd:`Return` while on any previous command retrieves that command |
| 266 | |
| 267 | * :kbd:`Alt-/` (Expand word) is also useful here |
| 268 | |
| 269 | .. index:: single: indentation |
| 270 | |
| 271 | |
| 272 | Syntax colors |
| 273 | ------------- |
| 274 | |
| 275 | The coloring is applied in a background "thread," so you may occasionally see |
| 276 | uncolorized text. To change the color scheme, edit the ``[Colors]`` section in |
| 277 | :file:`config.txt`. |
| 278 | |
| 279 | Python syntax colors: |
| 280 | Keywords |
| 281 | orange |
| 282 | |
Georg Brandl | 48310cd | 2009-01-03 21:18:54 +0000 | [diff] [blame] | 283 | Strings |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 284 | green |
| 285 | |
| 286 | Comments |
| 287 | red |
| 288 | |
| 289 | Definitions |
| 290 | blue |
| 291 | |
| 292 | Shell colors: |
| 293 | Console output |
| 294 | brown |
| 295 | |
| 296 | stdout |
| 297 | blue |
| 298 | |
| 299 | stderr |
| 300 | dark green |
| 301 | |
| 302 | stdin |
| 303 | black |
| 304 | |
| 305 | |
Benjamin Peterson | f07d002 | 2009-03-21 17:31:58 +0000 | [diff] [blame] | 306 | Startup |
| 307 | ------- |
| 308 | |
| 309 | Upon startup with the ``-s`` option, IDLE will execute the file referenced by |
| 310 | the environment variables :envvar:`IDLESTARTUP` or :envvar:`PYTHONSTARTUP`. |
| 311 | Idle first checks for ``IDLESTARTUP``; if ``IDLESTARTUP`` is present the file |
| 312 | referenced is run. If ``IDLESTARTUP`` is not present, Idle checks for |
| 313 | ``PYTHONSTARTUP``. Files referenced by these environment variables are |
| 314 | convenient places to store functions that are used frequently from the Idle |
| 315 | shell, or for executing import statements to import common modules. |
| 316 | |
| 317 | In addition, ``Tk`` also loads a startup file if it is present. Note that the |
| 318 | Tk file is loaded unconditionally. This additional file is ``.Idle.py`` and is |
| 319 | looked for in the user's home directory. Statements in this file will be |
| 320 | executed in the Tk namespace, so this file is not useful for importing functions |
| 321 | to be used from Idle's Python shell. |
| 322 | |
| 323 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 324 | Command line usage |
| 325 | ^^^^^^^^^^^^^^^^^^ |
| 326 | |
| 327 | :: |
| 328 | |
| 329 | idle.py [-c command] [-d] [-e] [-s] [-t title] [arg] ... |
| 330 | |
| 331 | -c command run this command |
| 332 | -d enable debugger |
| 333 | -e edit mode; arguments are files to be edited |
| 334 | -s run $IDLESTARTUP or $PYTHONSTARTUP first |
| 335 | -t title set title of shell window |
| 336 | |
| 337 | If there are arguments: |
| 338 | |
Éric Araujo | 713d303 | 2010-11-18 16:38:46 +0000 | [diff] [blame] | 339 | #. If ``-e`` is used, arguments are files opened for editing and |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 340 | ``sys.argv`` reflects the arguments passed to IDLE itself. |
| 341 | |
Éric Araujo | 713d303 | 2010-11-18 16:38:46 +0000 | [diff] [blame] | 342 | #. Otherwise, if ``-c`` is used, all arguments are placed in |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 343 | ``sys.argv[1:...]``, with ``sys.argv[0]`` set to ``'-c'``. |
| 344 | |
Éric Araujo | 713d303 | 2010-11-18 16:38:46 +0000 | [diff] [blame] | 345 | #. Otherwise, if neither ``-e`` nor ``-c`` is used, the first |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 346 | argument is a script which is executed with the remaining arguments in |
| 347 | ``sys.argv[1:...]`` and ``sys.argv[0]`` set to the script name. If the script |
| 348 | name is '-', no script is executed but an interactive Python session is started; |
| 349 | the arguments are still available in ``sys.argv``. |
| 350 | |
| 351 | |