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