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 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 19 | * cross-platform: works on Windows, Unix, and Mac OS X |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 20 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 21 | * multi-window text editor with multiple undo, Python colorizing, |
| 22 | smart indent, call tips, and many other features |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 23 | |
| 24 | * Python shell window (a.k.a. interactive interpreter) |
| 25 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 26 | * debugger (not complete, but you can set breakpoints, view and step) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 27 | |
| 28 | |
| 29 | Menus |
| 30 | ----- |
| 31 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 32 | IDLE has two window types, the Shell window and the Editor window. It is |
| 33 | possible to have multiple editor windows simultaneously. IDLE's |
| 34 | menus dynamically change based on which window is currently selected. Each menu |
| 35 | documented below indicates which window type it is associated with. Click on |
| 36 | the dotted line at the top of a menu to "tear it off": a separate window |
| 37 | containing the menu is created (for Unix and Windows only). |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 38 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 39 | File menu (Shell and Editor) |
| 40 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 41 | |
Terry Jan Reedy | 8a0b775 | 2013-07-01 00:42:52 -0400 | [diff] [blame] | 42 | New file |
Terry Jan Reedy | ec4bdac | 2013-07-01 00:52:18 -0400 | [diff] [blame^] | 43 | Create a new file editing window |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 44 | |
| 45 | Open... |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 46 | Open an existing file |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 47 | |
| 48 | Open module... |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 49 | Open an existing module (searches sys.path) |
| 50 | |
| 51 | Recent Files |
| 52 | Open a list of recent files |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 53 | |
| 54 | Class browser |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 55 | Show classes and methods in current file |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 56 | |
| 57 | Path browser |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 58 | Show sys.path directories, modules, classes and methods |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 59 | |
| 60 | .. index:: |
| 61 | single: Class browser |
| 62 | single: Path browser |
| 63 | |
| 64 | Save |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 65 | Save current window to the associated file (unsaved windows have a |
| 66 | \* before and after the window title) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 67 | |
| 68 | Save As... |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 69 | Save current window to new file, which becomes the associated file |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 70 | |
| 71 | Save Copy As... |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 72 | Save current window to different file without changing the associated file |
| 73 | |
| 74 | Print Window |
| 75 | Print the current window |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 76 | |
| 77 | Close |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 78 | Close current window (asks to save if unsaved) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 79 | |
| 80 | Exit |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 81 | Close all windows and quit IDLE (asks to save if unsaved) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 82 | |
| 83 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 84 | Edit menu (Shell and Editor) |
| 85 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 86 | |
| 87 | Undo |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 88 | Undo last change to current window (a maximum of 1000 changes may be undone) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 89 | |
| 90 | Redo |
| 91 | Redo last undone change to current window |
| 92 | |
| 93 | Cut |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 94 | Copy selection into system-wide clipboard; then delete the selection |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 95 | |
| 96 | Copy |
| 97 | Copy selection into system-wide clipboard |
| 98 | |
| 99 | Paste |
| 100 | Insert system-wide clipboard into window |
| 101 | |
| 102 | Select All |
| 103 | Select the entire contents of the edit buffer |
| 104 | |
| 105 | Find... |
| 106 | Open a search dialog box with many options |
| 107 | |
| 108 | Find again |
| 109 | Repeat last search |
| 110 | |
| 111 | Find selection |
| 112 | Search for the string in the selection |
| 113 | |
| 114 | Find in Files... |
| 115 | Open a search dialog box for searching files |
| 116 | |
| 117 | Replace... |
| 118 | Open a search-and-replace dialog box |
| 119 | |
| 120 | Go to line |
| 121 | Ask for a line number and show that line |
| 122 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 123 | Expand word |
| 124 | Expand the word you have typed to match another word in the same buffer; |
| 125 | repeat to get a different expansion |
| 126 | |
| 127 | Show call tip |
| 128 | After an unclosed parenthesis for a function, open a small window with |
| 129 | function parameter hints |
| 130 | |
| 131 | Show surrounding parens |
| 132 | Highlight the surrounding parenthesis |
| 133 | |
| 134 | Show Completions |
| 135 | Open a scroll window allowing selection keywords and attributes. See |
| 136 | Completions below. |
| 137 | |
| 138 | |
| 139 | Format menu (Editor window only) |
| 140 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 141 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 142 | Indent region |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 143 | Shift selected lines right by the indent width (default 4 spaces) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 144 | |
| 145 | Dedent region |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 146 | Shift selected lines left by the indent width (default 4 spaces) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 147 | |
| 148 | Comment out region |
| 149 | Insert ## in front of selected lines |
| 150 | |
| 151 | Uncomment region |
| 152 | Remove leading # or ## from selected lines |
| 153 | |
| 154 | Tabify region |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 155 | Turns *leading* stretches of spaces into tabs. (Note: We recommend using |
| 156 | 4 space blocks to indent Python code.) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 157 | |
| 158 | Untabify region |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 159 | Turn *all* tabs into the correct number of spaces |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 160 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 161 | Toggle tabs |
| 162 | Open a dialog to switch between indenting with spaces and tabs. |
| 163 | |
| 164 | New Indent Width |
| 165 | Open a dialog to change indent width. The accepted default by the Python |
| 166 | community is 4 spaces. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 167 | |
| 168 | Format Paragraph |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 169 | Reformat the current blank-line-separated paragraph. All lines in the |
| 170 | paragraph will be formatted to less than 80 columns. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 171 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 172 | Strip trailing whitespace |
| 173 | Removes any space characters after the end of the last non-space character |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 174 | |
| 175 | .. index:: |
| 176 | single: Import module |
| 177 | single: Run script |
| 178 | |
| 179 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 180 | Run menu (Editor window only) |
| 181 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 182 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 183 | Python Shell |
| 184 | Open or wake up the Python Shell window |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 185 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 186 | Check module |
| 187 | Check the syntax of the module currently open in the Editor window. If the |
| 188 | module has not been saved IDLE will prompt the user to save the code. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 189 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 190 | Run module |
| 191 | Restart the shell to clean the environment, then execute the currently |
| 192 | open module. If the module has not been saved IDLE will prompt the user |
| 193 | to save the code. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 194 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 195 | Shell menu (Shell window only) |
| 196 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Ned Deily | 2778d0d | 2012-10-20 13:25:34 -0700 | [diff] [blame] | 197 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 198 | View Last Restart |
| 199 | Scroll the shell window to the last Shell restart |
| 200 | |
| 201 | Restart Shell |
| 202 | Restart the shell to clean the environment |
| 203 | |
| 204 | Debug menu (Shell window only) |
| 205 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 206 | |
| 207 | Go to file/line |
Ned Deily | 2778d0d | 2012-10-20 13:25:34 -0700 | [diff] [blame] | 208 | Look around the insert point for a filename and line number, open the file, |
| 209 | and show the line. Useful to view the source lines referenced in an |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 210 | exception traceback. Available in the context menu of the Shell window. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 211 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 212 | Debugger (toggle) |
| 213 | This feature is not complete and considered experimental. Run commands in |
| 214 | the shell under the debugger |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 215 | |
Ned Deily | 2778d0d | 2012-10-20 13:25:34 -0700 | [diff] [blame] | 216 | Stack viewer |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 217 | Show the stack traceback of the last exception |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 218 | |
Ned Deily | 2778d0d | 2012-10-20 13:25:34 -0700 | [diff] [blame] | 219 | Auto-open Stack Viewer |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 220 | Toggle automatically opening the stack viewer on unhandled exception |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 221 | |
| 222 | .. index:: |
| 223 | single: stack viewer |
| 224 | single: debugger |
| 225 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 226 | Options menu (Shell and Editor) |
| 227 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 228 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 229 | Configure IDLE |
| 230 | Open a configuration dialog. Fonts, indentation, keybindings, and color |
| 231 | themes may be altered. Startup Preferences may be set, and additional |
| 232 | help sources can be specified. |
Ned Deily | 2778d0d | 2012-10-20 13:25:34 -0700 | [diff] [blame] | 233 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 234 | Code Context (toggle)(Editor Window only) |
| 235 | Open a pane at the top of the edit window which shows the block context |
| 236 | of the section of code which is scrolling off the top of the window. |
| 237 | |
| 238 | Windows menu (Shell and Editor) |
| 239 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 240 | |
| 241 | Zoom Height |
| 242 | Toggles the window between normal size (40x80 initial setting) and maximum |
| 243 | height. The initial size is in the Configure IDLE dialog under the general |
| 244 | tab. |
| 245 | |
| 246 | The rest of this menu lists the names of all open windows; select one to bring |
| 247 | it to the foreground (deiconifying it if necessary). |
| 248 | |
| 249 | Help menu (Shell and Editor) |
| 250 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 251 | |
| 252 | About IDLE |
| 253 | Version, copyright, license, credits |
| 254 | |
| 255 | IDLE Help |
| 256 | Display a help file for IDLE detailing the menu options, basic editing and |
| 257 | navigation, and other tips. |
| 258 | |
| 259 | Python Docs |
| 260 | Access local Python documentation, if installed. Or will start a web browser |
| 261 | and open docs.python.org showing the latest Python documentation. |
| 262 | |
| 263 | Additional help sources may be added here with the Configure IDLE dialog under |
| 264 | the General tab. |
| 265 | |
| 266 | Editor Window context menu |
| 267 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 268 | |
| 269 | * Right-click in Editor window (Control-click on OS X) |
Ned Deily | 2778d0d | 2012-10-20 13:25:34 -0700 | [diff] [blame] | 270 | |
Andrew Svetlov | d183767 | 2012-11-01 22:41:19 +0200 | [diff] [blame] | 271 | Cut |
| 272 | Copy selection into system-wide clipboard; then delete selection |
| 273 | |
| 274 | Copy |
| 275 | Copy selection into system-wide clipboard |
| 276 | |
| 277 | Paste |
| 278 | Insert system-wide clipboard into window |
| 279 | |
Ned Deily | 2778d0d | 2012-10-20 13:25:34 -0700 | [diff] [blame] | 280 | Set Breakpoint |
| 281 | Sets a breakpoint. Breakpoints are only enabled when the debugger is open. |
| 282 | |
| 283 | Clear Breakpoint |
| 284 | Clears the breakpoint on that line. |
| 285 | |
| 286 | .. index:: |
Andrew Svetlov | d183767 | 2012-11-01 22:41:19 +0200 | [diff] [blame] | 287 | single: Cut |
| 288 | single: Copy |
| 289 | single: Paste |
Ned Deily | 2778d0d | 2012-10-20 13:25:34 -0700 | [diff] [blame] | 290 | single: Set Breakpoint |
| 291 | single: Clear Breakpoint |
| 292 | single: breakpoints |
| 293 | |
| 294 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 295 | Shell Window context menu |
| 296 | ^^^^^^^^^^^^^^^^^^^^^^^^^ |
Ned Deily | 2778d0d | 2012-10-20 13:25:34 -0700 | [diff] [blame] | 297 | |
| 298 | * Right-click in Python Shell window (Control-click on OS X) |
| 299 | |
Andrew Svetlov | d183767 | 2012-11-01 22:41:19 +0200 | [diff] [blame] | 300 | Cut |
| 301 | Copy selection into system-wide clipboard; then delete selection |
| 302 | |
| 303 | Copy |
| 304 | Copy selection into system-wide clipboard |
| 305 | |
| 306 | Paste |
| 307 | Insert system-wide clipboard into window |
| 308 | |
Ned Deily | 2778d0d | 2012-10-20 13:25:34 -0700 | [diff] [blame] | 309 | Go to file/line |
| 310 | Same as in Debug menu. |
| 311 | |
| 312 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 313 | Editing and navigation |
| 314 | ---------------------- |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 315 | |
| 316 | * :kbd:`Backspace` deletes to the left; :kbd:`Del` deletes to the right |
| 317 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 318 | * :kbd:`C-Backspace` delete word left; :kbd:`C-Del` delete word to the right |
| 319 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 320 | * Arrow keys and :kbd:`Page Up`/:kbd:`Page Down` to move around |
| 321 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 322 | * :kbd:`C-LeftArrow` and :kbd:`C-RightArrow` moves by words |
| 323 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 324 | * :kbd:`Home`/:kbd:`End` go to begin/end of line |
| 325 | |
| 326 | * :kbd:`C-Home`/:kbd:`C-End` go to begin/end of file |
| 327 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 328 | * Some useful Emacs bindings are inherited from Tcl/Tk: |
| 329 | |
| 330 | * :kbd:`C-a` beginning of line |
| 331 | |
| 332 | * :kbd:`C-e` end of line |
| 333 | |
| 334 | * :kbd:`C-k` kill line (but doesn't put it in clipboard) |
| 335 | |
| 336 | * :kbd:`C-l` center window around the insertion point |
| 337 | |
| 338 | * :kbd:`C-b` go backwards one character without deleting (usually you can |
| 339 | also use the cursor key for this) |
| 340 | |
| 341 | * :kbd:`C-f` go forward one character without deleting (usually you can |
| 342 | also use the cursor key for this) |
| 343 | |
| 344 | * :kbd:`C-p` go up one line (usually you can also use the cursor key for |
| 345 | this) |
| 346 | |
| 347 | * :kbd:`C-d` delete next character |
| 348 | |
| 349 | Standard keybindings (like :kbd:`C-c` to copy and :kbd:`C-v` to paste) |
| 350 | may work. Keybindings are selected in the Configure IDLE dialog. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 351 | |
| 352 | |
| 353 | Automatic indentation |
| 354 | ^^^^^^^^^^^^^^^^^^^^^ |
| 355 | |
| 356 | After a block-opening statement, the next line is indented by 4 spaces (in the |
| 357 | Python Shell window by one tab). After certain keywords (break, return etc.) |
| 358 | the next line is dedented. In leading indentation, :kbd:`Backspace` deletes up |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 359 | to 4 spaces if they are there. :kbd:`Tab` inserts spaces (in the Python |
| 360 | Shell window one tab), number depends on Indent width. Currently tabs |
| 361 | are restricted to four spaces due to Tcl/Tk limitations. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 362 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 363 | See also the indent/dedent region commands in the edit menu. |
| 364 | |
| 365 | Completions |
| 366 | ^^^^^^^^^^^ |
| 367 | |
| 368 | Completions are supplied for functions, classes, and attributes of classes, |
| 369 | both built-in and user-defined. Completions are also provided for |
| 370 | filenames. |
| 371 | |
| 372 | The AutoCompleteWindow (ACW) will open after a predefined delay (default is |
| 373 | two seconds) after a '.' or (in a string) an os.sep is typed. If after one |
| 374 | of those characters (plus zero or more other characters) a tab is typed |
| 375 | the ACW will open immediately if a possible continuation is found. |
| 376 | |
| 377 | If there is only one possible completion for the characters entered, a |
| 378 | :kbd:`Tab` will supply that completion without opening the ACW. |
| 379 | |
| 380 | 'Show Completions' will force open a completions window, by default the |
| 381 | :kbd:`C-space` will open a completions window. In an empty |
| 382 | string, this will contain the files in the current directory. On a |
| 383 | blank line, it will contain the built-in and user-defined functions and |
| 384 | classes in the current name spaces, plus any modules imported. If some |
| 385 | characters have been entered, the ACW will attempt to be more specific. |
| 386 | |
| 387 | If a string of characters is typed, the ACW selection will jump to the |
| 388 | entry most closely matching those characters. Entering a :kbd:`tab` will |
| 389 | cause the longest non-ambiguous match to be entered in the Editor window or |
| 390 | Shell. Two :kbd:`tab` in a row will supply the current ACW selection, as |
| 391 | will return or a double click. Cursor keys, Page Up/Down, mouse selection, |
| 392 | and the scroll wheel all operate on the ACW. |
| 393 | |
| 394 | "Hidden" attributes can be accessed by typing the beginning of hidden |
| 395 | name after a '.', e.g. '_'. This allows access to modules with |
| 396 | ``__all__`` set, or to class-private attributes. |
| 397 | |
| 398 | Completions and the 'Expand Word' facility can save a lot of typing! |
| 399 | |
| 400 | Completions are currently limited to those in the namespaces. Names in |
| 401 | an Editor window which are not via ``__main__`` and :data:`sys.modules` will |
| 402 | not be found. Run the module once with your imports to correct this situation. |
| 403 | Note that IDLE itself places quite a few modules in sys.modules, so |
| 404 | much can be found by default, e.g. the re module. |
| 405 | |
| 406 | If you don't like the ACW popping up unbidden, simply make the delay |
| 407 | longer or disable the extension. Or another option is the delay could |
| 408 | be set to zero. Another alternative to preventing ACW popups is to |
| 409 | disable the call tips extension. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 410 | |
| 411 | Python Shell window |
| 412 | ^^^^^^^^^^^^^^^^^^^ |
| 413 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 414 | * :kbd:`C-c` interrupts executing command |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 415 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 416 | * :kbd:`C-d` sends end-of-file; closes window if typed at a ``>>>`` prompt |
| 417 | (this is :kbd:`C-z` on Windows). |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 418 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 419 | * :kbd:`Alt-/` (Expand word) is also useful to reduce typing |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 420 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 421 | Command history |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 422 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 423 | * :kbd:`Alt-p` retrieves previous command matching what you have typed. On |
| 424 | OS X use :kbd:`C-p`. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 425 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 426 | * :kbd:`Alt-n` retrieves next. On OS X use :kbd:`C-n`. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 427 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 428 | * :kbd:`Return` while on any previous command retrieves that command |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 429 | |
| 430 | |
| 431 | Syntax colors |
| 432 | ------------- |
| 433 | |
| 434 | The coloring is applied in a background "thread," so you may occasionally see |
| 435 | uncolorized text. To change the color scheme, edit the ``[Colors]`` section in |
| 436 | :file:`config.txt`. |
| 437 | |
| 438 | Python syntax colors: |
| 439 | Keywords |
| 440 | orange |
| 441 | |
Georg Brandl | 48310cd | 2009-01-03 21:18:54 +0000 | [diff] [blame] | 442 | Strings |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 443 | green |
| 444 | |
| 445 | Comments |
| 446 | red |
| 447 | |
| 448 | Definitions |
| 449 | blue |
| 450 | |
| 451 | Shell colors: |
| 452 | Console output |
| 453 | brown |
| 454 | |
| 455 | stdout |
| 456 | blue |
| 457 | |
| 458 | stderr |
| 459 | dark green |
| 460 | |
| 461 | stdin |
| 462 | black |
| 463 | |
| 464 | |
Benjamin Peterson | f07d002 | 2009-03-21 17:31:58 +0000 | [diff] [blame] | 465 | Startup |
| 466 | ------- |
| 467 | |
| 468 | Upon startup with the ``-s`` option, IDLE will execute the file referenced by |
| 469 | the environment variables :envvar:`IDLESTARTUP` or :envvar:`PYTHONSTARTUP`. |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 470 | IDLE first checks for ``IDLESTARTUP``; if ``IDLESTARTUP`` is present the file |
| 471 | referenced is run. If ``IDLESTARTUP`` is not present, IDLE checks for |
Benjamin Peterson | f07d002 | 2009-03-21 17:31:58 +0000 | [diff] [blame] | 472 | ``PYTHONSTARTUP``. Files referenced by these environment variables are |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 473 | convenient places to store functions that are used frequently from the IDLE |
Benjamin Peterson | f07d002 | 2009-03-21 17:31:58 +0000 | [diff] [blame] | 474 | shell, or for executing import statements to import common modules. |
| 475 | |
| 476 | In addition, ``Tk`` also loads a startup file if it is present. Note that the |
| 477 | Tk file is loaded unconditionally. This additional file is ``.Idle.py`` and is |
| 478 | looked for in the user's home directory. Statements in this file will be |
| 479 | executed in the Tk namespace, so this file is not useful for importing functions |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 480 | to be used from IDLE's Python shell. |
Benjamin Peterson | f07d002 | 2009-03-21 17:31:58 +0000 | [diff] [blame] | 481 | |
| 482 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 483 | Command line usage |
| 484 | ^^^^^^^^^^^^^^^^^^ |
| 485 | |
| 486 | :: |
| 487 | |
| 488 | idle.py [-c command] [-d] [-e] [-s] [-t title] [arg] ... |
| 489 | |
| 490 | -c command run this command |
| 491 | -d enable debugger |
| 492 | -e edit mode; arguments are files to be edited |
| 493 | -s run $IDLESTARTUP or $PYTHONSTARTUP first |
| 494 | -t title set title of shell window |
| 495 | |
| 496 | If there are arguments: |
| 497 | |
Éric Araujo | 713d303 | 2010-11-18 16:38:46 +0000 | [diff] [blame] | 498 | #. If ``-e`` is used, arguments are files opened for editing and |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 499 | ``sys.argv`` reflects the arguments passed to IDLE itself. |
| 500 | |
Éric Araujo | 713d303 | 2010-11-18 16:38:46 +0000 | [diff] [blame] | 501 | #. Otherwise, if ``-c`` is used, all arguments are placed in |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 502 | ``sys.argv[1:...]``, with ``sys.argv[0]`` set to ``'-c'``. |
| 503 | |
Éric Araujo | 713d303 | 2010-11-18 16:38:46 +0000 | [diff] [blame] | 504 | #. Otherwise, if neither ``-e`` nor ``-c`` is used, the first |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 505 | argument is a script which is executed with the remaining arguments in |
| 506 | ``sys.argv[1:...]`` and ``sys.argv[0]`` set to the script name. If the script |
| 507 | name is '-', no script is executed but an interactive Python session is started; |
| 508 | the arguments are still available in ``sys.argv``. |
| 509 | |
| 510 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 511 | Additional help sources |
| 512 | ----------------------- |
| 513 | |
| 514 | IDLE includes a help menu entry called "Python Docs" that will open the |
| 515 | extensive sources of help, including tutorials, available at docs.python.org. |
| 516 | Selected URLs can be added or removed from the help menu at any time using the |
| 517 | Configure IDLE dialog. See the IDLE help option in the help menu of IDLE for |
| 518 | more information. |
| 519 | |
| 520 | |
| 521 | Other preferences |
| 522 | ----------------- |
| 523 | |
| 524 | The font preferences, highlighting, keys, and general preferences can be |
| 525 | changed via the Configure IDLE menu option. Be sure to note that |
| 526 | keys can be user defined, IDLE ships with four built in key sets. In |
| 527 | addition a user can create a custom key set in the Configure IDLE dialog |
| 528 | under the keys tab. |
| 529 | |
| 530 | Extensions |
| 531 | ---------- |
| 532 | |
| 533 | IDLE contains an extension facility. See the beginning of |
| 534 | config-extensions.def in the idlelib directory for further information. The |
| 535 | default extensions are currently: |
| 536 | |
| 537 | * FormatParagraph |
| 538 | |
| 539 | * AutoExpand |
| 540 | |
| 541 | * ZoomHeight |
| 542 | |
| 543 | * ScriptBinding |
| 544 | |
| 545 | * CallTips |
| 546 | |
| 547 | * ParenMatch |
| 548 | |
| 549 | * AutoComplete |
| 550 | |
| 551 | * CodeContext |
| 552 | |