Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 1 | .. _idle: |
| 2 | |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 3 | .. index:: |
Georg Brandl | b19be57 | 2007-12-29 10:57:00 +0000 | [diff] [blame] | 4 | single: IDLE |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 5 | single: Python Editor |
| 6 | single: Integrated Development Environment |
| 7 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 8 | IDLE |
| 9 | ==== |
| 10 | |
| 11 | .. moduleauthor:: Guido van Rossum <guido@Python.org> |
| 12 | |
Georg Brandl | c21cd7e | 2008-05-16 17:37:53 +0000 | [diff] [blame] | 13 | IDLE is the Python IDE built with the :mod:`tkinter` GUI toolkit. |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 14 | |
| 15 | IDLE has the following features: |
| 16 | |
Georg Brandl | c21cd7e | 2008-05-16 17:37:53 +0000 | [diff] [blame] | 17 | * coded in 100% pure Python, using the :mod:`tkinter` GUI toolkit |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 18 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 19 | * cross-platform: works on Windows, Unix, and Mac OS X |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 20 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 21 | * multi-window text editor with multiple undo, Python colorizing, |
| 22 | smart indent, call tips, and many other features |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 23 | |
| 24 | * Python shell window (a.k.a. interactive interpreter) |
| 25 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 26 | * debugger (not complete, but you can set breakpoints, view and step) |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 27 | |
| 28 | |
| 29 | Menus |
| 30 | ----- |
| 31 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [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 | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 38 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 39 | File menu (Shell and Editor) |
| 40 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 41 | |
Terry Jan Reedy | 44d8b11 | 2013-07-01 00:42:44 -0400 | [diff] [blame] | 42 | New file |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 43 | Create a new file editing window |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 44 | |
| 45 | Open... |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 46 | Open an existing file |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 47 | |
| 48 | Open module... |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 49 | Open an existing module (searches sys.path) |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 50 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 51 | Recent Files |
| 52 | Open a list of recent files |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 53 | |
| 54 | .. index:: |
| 55 | single: Class browser |
| 56 | single: Path browser |
| 57 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 58 | Class browser |
| 59 | Show classes and methods in current file |
| 60 | |
| 61 | Path browser |
| 62 | Show sys.path directories, modules, classes and methods |
| 63 | |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 64 | Save |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 65 | Save current window to the associated file (unsaved windows have a |
| 66 | \* before and after the window title) |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 67 | |
| 68 | Save As... |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 69 | Save current window to new file, which becomes the associated file |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 70 | |
| 71 | Save Copy As... |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [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 | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 76 | |
| 77 | Close |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 78 | Close current window (asks to save if unsaved) |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 79 | |
| 80 | Exit |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 81 | Close all windows and quit IDLE (asks to save if unsaved) |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 82 | |
| 83 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 84 | Edit menu (Shell and Editor) |
| 85 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 86 | |
| 87 | Undo |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 88 | Undo last change to current window (a maximum of 1000 changes may be undone) |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 89 | |
| 90 | Redo |
| 91 | Redo last undone change to current window |
| 92 | |
| 93 | Cut |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 94 | Copy selection into system-wide clipboard; then delete the selection |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +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 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [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 | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 142 | Indent region |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 143 | Shift selected lines right by the indent width (default 4 spaces) |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 144 | |
| 145 | Dedent region |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 146 | Shift selected lines left by the indent width (default 4 spaces) |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +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 |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 155 | Turns *leading* stretches of spaces into tabs. (Note: We recommend using |
| 156 | 4 space blocks to indent Python code.) |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 157 | |
| 158 | Untabify region |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 159 | Turn *all* tabs into the correct number of spaces |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 160 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [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 | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 167 | |
| 168 | Format Paragraph |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [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 | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 171 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 172 | Strip trailing whitespace |
| 173 | Removes any space characters after the end of the last non-space character |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 174 | |
| 175 | .. index:: |
| 176 | single: Import module |
| 177 | single: Run script |
| 178 | |
| 179 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 180 | Run menu (Editor window only) |
| 181 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 182 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 183 | Python Shell |
| 184 | Open or wake up the Python Shell window |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 185 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [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 | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 189 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [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 | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 194 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 195 | Shell menu (Shell window only) |
| 196 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Ned Deily | c859bd2 | 2012-10-20 13:23:25 -0700 | [diff] [blame] | 197 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [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 | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 206 | |
| 207 | Go to file/line |
Ned Deily | c859bd2 | 2012-10-20 13:23:25 -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 |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 210 | exception traceback. Available in the context menu of the Shell window. |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 211 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [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 | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 215 | |
Ned Deily | c859bd2 | 2012-10-20 13:23:25 -0700 | [diff] [blame] | 216 | Stack viewer |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 217 | Show the stack traceback of the last exception |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 218 | |
Ned Deily | c859bd2 | 2012-10-20 13:23:25 -0700 | [diff] [blame] | 219 | Auto-open Stack Viewer |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 220 | Toggle automatically opening the stack viewer on unhandled exception |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 221 | |
| 222 | .. index:: |
| 223 | single: stack viewer |
| 224 | single: debugger |
| 225 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 226 | Options menu (Shell and Editor) |
| 227 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 228 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [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 | c859bd2 | 2012-10-20 13:23:25 -0700 | [diff] [blame] | 233 | |
Terry Jan Reedy | 9e466cf | 2014-12-04 01:22:41 -0500 | [diff] [blame^] | 234 | Configure Extensions |
| 235 | Open a configuration dialog for setting preferences for extensions |
| 236 | (discussed below). |
| 237 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 238 | Code Context (toggle)(Editor Window only) |
| 239 | Open a pane at the top of the edit window which shows the block context |
| 240 | of the section of code which is scrolling off the top of the window. |
| 241 | |
| 242 | Windows menu (Shell and Editor) |
| 243 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 244 | |
| 245 | Zoom Height |
| 246 | Toggles the window between normal size (40x80 initial setting) and maximum |
| 247 | height. The initial size is in the Configure IDLE dialog under the general |
| 248 | tab. |
| 249 | |
| 250 | The rest of this menu lists the names of all open windows; select one to bring |
| 251 | it to the foreground (deiconifying it if necessary). |
| 252 | |
| 253 | Help menu (Shell and Editor) |
| 254 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 255 | |
| 256 | About IDLE |
| 257 | Version, copyright, license, credits |
| 258 | |
| 259 | IDLE Help |
| 260 | Display a help file for IDLE detailing the menu options, basic editing and |
| 261 | navigation, and other tips. |
| 262 | |
| 263 | Python Docs |
| 264 | Access local Python documentation, if installed. Or will start a web browser |
| 265 | and open docs.python.org showing the latest Python documentation. |
| 266 | |
| 267 | Additional help sources may be added here with the Configure IDLE dialog under |
| 268 | the General tab. |
| 269 | |
| 270 | .. index:: |
| 271 | single: Cut |
| 272 | single: Copy |
| 273 | single: Paste |
| 274 | single: Set Breakpoint |
| 275 | single: Clear Breakpoint |
| 276 | single: breakpoints |
| 277 | |
| 278 | Editor Window context menu |
| 279 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 280 | |
| 281 | * Right-click in Editor window (Control-click on OS X) |
Ned Deily | c859bd2 | 2012-10-20 13:23:25 -0700 | [diff] [blame] | 282 | |
Andrew Svetlov | 5018db7 | 2012-11-01 22:39:14 +0200 | [diff] [blame] | 283 | Cut |
| 284 | Copy selection into system-wide clipboard; then delete selection |
| 285 | |
| 286 | Copy |
| 287 | Copy selection into system-wide clipboard |
| 288 | |
| 289 | Paste |
| 290 | Insert system-wide clipboard into window |
| 291 | |
Ned Deily | c859bd2 | 2012-10-20 13:23:25 -0700 | [diff] [blame] | 292 | Set Breakpoint |
| 293 | Sets a breakpoint. Breakpoints are only enabled when the debugger is open. |
| 294 | |
| 295 | Clear Breakpoint |
| 296 | Clears the breakpoint on that line. |
| 297 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 298 | Shell Window context menu |
| 299 | ^^^^^^^^^^^^^^^^^^^^^^^^^ |
Ned Deily | c859bd2 | 2012-10-20 13:23:25 -0700 | [diff] [blame] | 300 | |
| 301 | * Right-click in Python Shell window (Control-click on OS X) |
| 302 | |
Andrew Svetlov | 5018db7 | 2012-11-01 22:39:14 +0200 | [diff] [blame] | 303 | Cut |
| 304 | Copy selection into system-wide clipboard; then delete selection |
| 305 | |
| 306 | Copy |
| 307 | Copy selection into system-wide clipboard |
| 308 | |
| 309 | Paste |
| 310 | Insert system-wide clipboard into window |
| 311 | |
Ned Deily | c859bd2 | 2012-10-20 13:23:25 -0700 | [diff] [blame] | 312 | Go to file/line |
| 313 | Same as in Debug menu. |
| 314 | |
| 315 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 316 | Editing and navigation |
| 317 | ---------------------- |
| 318 | |
| 319 | In this section, 'C' refers to the Control key on Windows and Unix and |
| 320 | the Command key on Mac OSX. |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 321 | |
| 322 | * :kbd:`Backspace` deletes to the left; :kbd:`Del` deletes to the right |
| 323 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 324 | * :kbd:`C-Backspace` delete word left; :kbd:`C-Del` delete word to the right |
| 325 | |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 326 | * Arrow keys and :kbd:`Page Up`/:kbd:`Page Down` to move around |
| 327 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 328 | * :kbd:`C-LeftArrow` and :kbd:`C-RightArrow` moves by words |
| 329 | |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 330 | * :kbd:`Home`/:kbd:`End` go to begin/end of line |
| 331 | |
| 332 | * :kbd:`C-Home`/:kbd:`C-End` go to begin/end of file |
| 333 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 334 | * Some useful Emacs bindings are inherited from Tcl/Tk: |
| 335 | |
| 336 | * :kbd:`C-a` beginning of line |
| 337 | |
| 338 | * :kbd:`C-e` end of line |
| 339 | |
| 340 | * :kbd:`C-k` kill line (but doesn't put it in clipboard) |
| 341 | |
| 342 | * :kbd:`C-l` center window around the insertion point |
| 343 | |
| 344 | * :kbd:`C-b` go backwards one character without deleting (usually you can |
| 345 | also use the cursor key for this) |
| 346 | |
| 347 | * :kbd:`C-f` go forward one character without deleting (usually you can |
| 348 | also use the cursor key for this) |
| 349 | |
| 350 | * :kbd:`C-p` go up one line (usually you can also use the cursor key for |
| 351 | this) |
| 352 | |
| 353 | * :kbd:`C-d` delete next character |
| 354 | |
| 355 | Standard keybindings (like :kbd:`C-c` to copy and :kbd:`C-v` to paste) |
| 356 | may work. Keybindings are selected in the Configure IDLE dialog. |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 357 | |
| 358 | |
| 359 | Automatic indentation |
| 360 | ^^^^^^^^^^^^^^^^^^^^^ |
| 361 | |
| 362 | After a block-opening statement, the next line is indented by 4 spaces (in the |
| 363 | Python Shell window by one tab). After certain keywords (break, return etc.) |
| 364 | the next line is dedented. In leading indentation, :kbd:`Backspace` deletes up |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 365 | to 4 spaces if they are there. :kbd:`Tab` inserts spaces (in the Python |
| 366 | Shell window one tab), number depends on Indent width. Currently tabs |
| 367 | are restricted to four spaces due to Tcl/Tk limitations. |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 368 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 369 | See also the indent/dedent region commands in the edit menu. |
| 370 | |
| 371 | Completions |
| 372 | ^^^^^^^^^^^ |
| 373 | |
| 374 | Completions are supplied for functions, classes, and attributes of classes, |
| 375 | both built-in and user-defined. Completions are also provided for |
| 376 | filenames. |
| 377 | |
| 378 | The AutoCompleteWindow (ACW) will open after a predefined delay (default is |
| 379 | two seconds) after a '.' or (in a string) an os.sep is typed. If after one |
| 380 | of those characters (plus zero or more other characters) a tab is typed |
| 381 | the ACW will open immediately if a possible continuation is found. |
| 382 | |
| 383 | If there is only one possible completion for the characters entered, a |
| 384 | :kbd:`Tab` will supply that completion without opening the ACW. |
| 385 | |
| 386 | 'Show Completions' will force open a completions window, by default the |
| 387 | :kbd:`C-space` will open a completions window. In an empty |
| 388 | string, this will contain the files in the current directory. On a |
| 389 | blank line, it will contain the built-in and user-defined functions and |
| 390 | classes in the current name spaces, plus any modules imported. If some |
| 391 | characters have been entered, the ACW will attempt to be more specific. |
| 392 | |
| 393 | If a string of characters is typed, the ACW selection will jump to the |
| 394 | entry most closely matching those characters. Entering a :kbd:`tab` will |
| 395 | cause the longest non-ambiguous match to be entered in the Editor window or |
| 396 | Shell. Two :kbd:`tab` in a row will supply the current ACW selection, as |
| 397 | will return or a double click. Cursor keys, Page Up/Down, mouse selection, |
| 398 | and the scroll wheel all operate on the ACW. |
| 399 | |
| 400 | "Hidden" attributes can be accessed by typing the beginning of hidden |
| 401 | name after a '.', e.g. '_'. This allows access to modules with |
| 402 | ``__all__`` set, or to class-private attributes. |
| 403 | |
| 404 | Completions and the 'Expand Word' facility can save a lot of typing! |
| 405 | |
| 406 | Completions are currently limited to those in the namespaces. Names in |
| 407 | an Editor window which are not via ``__main__`` and :data:`sys.modules` will |
| 408 | not be found. Run the module once with your imports to correct this situation. |
| 409 | Note that IDLE itself places quite a few modules in sys.modules, so |
| 410 | much can be found by default, e.g. the re module. |
| 411 | |
| 412 | If you don't like the ACW popping up unbidden, simply make the delay |
| 413 | longer or disable the extension. Or another option is the delay could |
| 414 | be set to zero. Another alternative to preventing ACW popups is to |
| 415 | disable the call tips extension. |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 416 | |
| 417 | Python Shell window |
| 418 | ^^^^^^^^^^^^^^^^^^^ |
| 419 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 420 | * :kbd:`C-c` interrupts executing command |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 421 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 422 | * :kbd:`C-d` sends end-of-file; closes window if typed at a ``>>>`` prompt |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 423 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 424 | * :kbd:`Alt-/` (Expand word) is also useful to reduce typing |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 425 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 426 | Command history |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 427 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 428 | * :kbd:`Alt-p` retrieves previous command matching what you have typed. On |
| 429 | OS X use :kbd:`C-p`. |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 430 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 431 | * :kbd:`Alt-n` retrieves next. On OS X use :kbd:`C-n`. |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 432 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 433 | * :kbd:`Return` while on any previous command retrieves that command |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 434 | |
| 435 | |
| 436 | Syntax colors |
| 437 | ------------- |
| 438 | |
| 439 | The coloring is applied in a background "thread," so you may occasionally see |
| 440 | uncolorized text. To change the color scheme, edit the ``[Colors]`` section in |
| 441 | :file:`config.txt`. |
| 442 | |
| 443 | Python syntax colors: |
| 444 | Keywords |
| 445 | orange |
| 446 | |
Georg Brandl | c62ef8b | 2009-01-03 20:55:06 +0000 | [diff] [blame] | 447 | Strings |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 448 | green |
| 449 | |
| 450 | Comments |
| 451 | red |
| 452 | |
| 453 | Definitions |
| 454 | blue |
| 455 | |
| 456 | Shell colors: |
| 457 | Console output |
| 458 | brown |
| 459 | |
| 460 | stdout |
| 461 | blue |
| 462 | |
| 463 | stderr |
| 464 | dark green |
| 465 | |
| 466 | stdin |
| 467 | black |
| 468 | |
| 469 | |
Georg Brandl | 09827eb | 2009-03-15 21:51:48 +0000 | [diff] [blame] | 470 | Startup |
| 471 | ------- |
| 472 | |
| 473 | Upon startup with the ``-s`` option, IDLE will execute the file referenced by |
| 474 | the environment variables :envvar:`IDLESTARTUP` or :envvar:`PYTHONSTARTUP`. |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 475 | IDLE first checks for ``IDLESTARTUP``; if ``IDLESTARTUP`` is present the file |
| 476 | referenced is run. If ``IDLESTARTUP`` is not present, IDLE checks for |
Georg Brandl | 09827eb | 2009-03-15 21:51:48 +0000 | [diff] [blame] | 477 | ``PYTHONSTARTUP``. Files referenced by these environment variables are |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 478 | convenient places to store functions that are used frequently from the IDLE |
Georg Brandl | 09827eb | 2009-03-15 21:51:48 +0000 | [diff] [blame] | 479 | shell, or for executing import statements to import common modules. |
| 480 | |
| 481 | In addition, ``Tk`` also loads a startup file if it is present. Note that the |
| 482 | Tk file is loaded unconditionally. This additional file is ``.Idle.py`` and is |
| 483 | looked for in the user's home directory. Statements in this file will be |
| 484 | executed in the Tk namespace, so this file is not useful for importing functions |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 485 | to be used from IDLE's Python shell. |
Georg Brandl | 09827eb | 2009-03-15 21:51:48 +0000 | [diff] [blame] | 486 | |
| 487 | |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 488 | Command line usage |
| 489 | ^^^^^^^^^^^^^^^^^^ |
| 490 | |
| 491 | :: |
| 492 | |
| 493 | idle.py [-c command] [-d] [-e] [-s] [-t title] [arg] ... |
| 494 | |
| 495 | -c command run this command |
| 496 | -d enable debugger |
| 497 | -e edit mode; arguments are files to be edited |
| 498 | -s run $IDLESTARTUP or $PYTHONSTARTUP first |
| 499 | -t title set title of shell window |
| 500 | |
| 501 | If there are arguments: |
| 502 | |
Éric Araujo | a8132ec | 2010-12-16 03:53:53 +0000 | [diff] [blame] | 503 | #. If ``-e`` is used, arguments are files opened for editing and |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 504 | ``sys.argv`` reflects the arguments passed to IDLE itself. |
| 505 | |
Éric Araujo | a8132ec | 2010-12-16 03:53:53 +0000 | [diff] [blame] | 506 | #. Otherwise, if ``-c`` is used, all arguments are placed in |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 507 | ``sys.argv[1:...]``, with ``sys.argv[0]`` set to ``'-c'``. |
| 508 | |
Éric Araujo | a8132ec | 2010-12-16 03:53:53 +0000 | [diff] [blame] | 509 | #. Otherwise, if neither ``-e`` nor ``-c`` is used, the first |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 510 | argument is a script which is executed with the remaining arguments in |
| 511 | ``sys.argv[1:...]`` and ``sys.argv[0]`` set to the script name. If the script |
| 512 | name is '-', no script is executed but an interactive Python session is started; |
| 513 | the arguments are still available in ``sys.argv``. |
| 514 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 515 | Running without a subprocess |
| 516 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 517 | |
| 518 | If IDLE is started with the -n command line switch it will run in a |
| 519 | single process and will not create the subprocess which runs the RPC |
| 520 | Python execution server. This can be useful if Python cannot create |
| 521 | the subprocess or the RPC socket interface on your platform. However, |
| 522 | in this mode user code is not isolated from IDLE itself. Also, the |
| 523 | environment is not restarted when Run/Run Module (F5) is selected. If |
| 524 | your code has been modified, you must reload() the affected modules and |
| 525 | re-import any specific items (e.g. from foo import baz) if the changes |
| 526 | are to take effect. For these reasons, it is preferable to run IDLE |
| 527 | with the default subprocess if at all possible. |
| 528 | |
| 529 | .. deprecated:: 3.4 |
| 530 | |
| 531 | |
Terry Jan Reedy | 9e466cf | 2014-12-04 01:22:41 -0500 | [diff] [blame^] | 532 | Help and preferences |
| 533 | -------------------- |
| 534 | |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 535 | Additional help sources |
Terry Jan Reedy | 9e466cf | 2014-12-04 01:22:41 -0500 | [diff] [blame^] | 536 | ^^^^^^^^^^^^^^^^^^^^^^^ |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 537 | |
| 538 | IDLE includes a help menu entry called "Python Docs" that will open the |
| 539 | extensive sources of help, including tutorials, available at docs.python.org. |
| 540 | Selected URLs can be added or removed from the help menu at any time using the |
| 541 | Configure IDLE dialog. See the IDLE help option in the help menu of IDLE for |
| 542 | more information. |
| 543 | |
| 544 | |
Terry Jan Reedy | 9e466cf | 2014-12-04 01:22:41 -0500 | [diff] [blame^] | 545 | Setting preferences |
| 546 | ^^^^^^^^^^^^^^^^^^^ |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 547 | |
| 548 | The font preferences, highlighting, keys, and general preferences can be |
Terry Jan Reedy | 9e466cf | 2014-12-04 01:22:41 -0500 | [diff] [blame^] | 549 | changed via Configure IDLE on the Option menu. Keys can be user defined; |
| 550 | IDLE ships with four built in key sets. In addition a user can create a |
| 551 | custom key set in the Configure IDLE dialog under the keys tab. |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 552 | |
| 553 | |
| 554 | Extensions |
Terry Jan Reedy | 9e466cf | 2014-12-04 01:22:41 -0500 | [diff] [blame^] | 555 | ^^^^^^^^^^ |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 556 | |
Terry Jan Reedy | 9e466cf | 2014-12-04 01:22:41 -0500 | [diff] [blame^] | 557 | IDLE contains an extension facility. Peferences for extensions can be |
| 558 | changed with Configure Extensions. See the beginning of config-extensions.def |
| 559 | in the idlelib directory for further information. The default extensions |
| 560 | are currently: |
Terry Jan Reedy | eb40589 | 2014-12-04 00:55:46 -0500 | [diff] [blame] | 561 | |
| 562 | * FormatParagraph |
| 563 | |
| 564 | * AutoExpand |
| 565 | |
| 566 | * ZoomHeight |
| 567 | |
| 568 | * ScriptBinding |
| 569 | |
| 570 | * CallTips |
| 571 | |
| 572 | * ParenMatch |
| 573 | |
| 574 | * AutoComplete |
| 575 | |
| 576 | * CodeContext |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 577 | |
Terry Jan Reedy | 9e466cf | 2014-12-04 01:22:41 -0500 | [diff] [blame^] | 578 | * RstripExtension |