Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 1 | .. _idle: |
| 2 | |
Ned Deily | 50afcc0 | 2015-02-06 15:42:06 +1100 | [diff] [blame] | 3 | IDLE |
| 4 | ==== |
| 5 | |
Terry Jan Reedy | fa089b9 | 2016-06-11 15:02:54 -0400 | [diff] [blame] | 6 | .. moduleauthor:: Guido van Rossum <guido@python.org> |
| 7 | |
| 8 | **Source code:** :source:`Lib/idlelib/` |
| 9 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 10 | .. index:: |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 11 | single: IDLE |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 12 | single: Python Editor |
| 13 | single: Integrated Development Environment |
| 14 | |
Terry Jan Reedy | fa089b9 | 2016-06-11 15:02:54 -0400 | [diff] [blame] | 15 | -------------- |
Terry Jan Reedy | f568494 | 2014-12-04 00:54:59 -0500 | [diff] [blame] | 16 | |
Terry Jan Reedy | d470527 | 2015-10-02 23:22:59 -0400 | [diff] [blame] | 17 | IDLE is Python's Integrated Development and Learning Environment. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 18 | |
| 19 | IDLE has the following features: |
| 20 | |
Georg Brandl | ac6060c | 2008-05-17 18:44:45 +0000 | [diff] [blame] | 21 | * coded in 100% pure Python, using the :mod:`tkinter` GUI toolkit |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 22 | |
Terry Jan Reedy | b65413b | 2018-11-15 13:15:13 -0500 | [diff] [blame] | 23 | * cross-platform: works mostly the same on Windows, Unix, and macOS |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 24 | |
Terry Jan Reedy | 6e10ec5 | 2015-09-23 20:00:33 -0400 | [diff] [blame] | 25 | * Python shell window (interactive interpreter) with colorizing |
| 26 | of code input, output, and error messages |
| 27 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 28 | * multi-window text editor with multiple undo, Python colorizing, |
Terry Jan Reedy | 6e10ec5 | 2015-09-23 20:00:33 -0400 | [diff] [blame] | 29 | smart indent, call tips, auto completion, and other features |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 30 | |
Terry Jan Reedy | 6e10ec5 | 2015-09-23 20:00:33 -0400 | [diff] [blame] | 31 | * search within any window, replace within editor windows, and search |
| 32 | through multiple files (grep) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 33 | |
Terry Jan Reedy | 6e10ec5 | 2015-09-23 20:00:33 -0400 | [diff] [blame] | 34 | * debugger with persistent breakpoints, stepping, and viewing |
| 35 | of global and local namespaces |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 36 | |
Terry Jan Reedy | 6e10ec5 | 2015-09-23 20:00:33 -0400 | [diff] [blame] | 37 | * configuration, browsers, and other dialogs |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 38 | |
| 39 | Menus |
| 40 | ----- |
| 41 | |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 42 | IDLE has two main window types, the Shell window and the Editor window. It is |
Terry Jan Reedy | 50ff02b | 2018-11-10 23:26:31 -0500 | [diff] [blame] | 43 | possible to have multiple editor windows simultaneously. On Windows and |
| 44 | Linux, each has its own top menu. Each menu documented below indicates |
| 45 | which window type it is associated with. |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 46 | |
Terry Jan Reedy | 50ff02b | 2018-11-10 23:26:31 -0500 | [diff] [blame] | 47 | Output windows, such as used for Edit => Find in Files, are a subtype of editor |
| 48 | window. They currently have the same top menu but a different |
| 49 | default title and context menu. |
| 50 | |
Terry Jan Reedy | b65413b | 2018-11-15 13:15:13 -0500 | [diff] [blame] | 51 | On macOS, there is one application menu. It dynamically changes according |
Terry Jan Reedy | 50ff02b | 2018-11-10 23:26:31 -0500 | [diff] [blame] | 52 | to the window currently selected. It has an IDLE menu, and some entries |
Terry Jan Reedy | 8a533ff | 2019-05-16 01:20:37 -0400 | [diff] [blame] | 53 | described below are moved around to conform to Apple guidelines. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 54 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 55 | File menu (Shell and Editor) |
| 56 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 57 | |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 58 | New File |
| 59 | Create a new file editing window. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 60 | |
| 61 | Open... |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 62 | Open an existing file with an Open dialog. |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 63 | |
| 64 | Recent Files |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 65 | Open a list of recent files. Click one to open it. |
| 66 | |
| 67 | Open Module... |
| 68 | Open an existing module (searches sys.path). |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 69 | |
Terry Jan Reedy | f568494 | 2014-12-04 00:54:59 -0500 | [diff] [blame] | 70 | .. index:: |
| 71 | single: Class browser |
| 72 | single: Path browser |
| 73 | |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 74 | Class Browser |
| 75 | Show functions, classes, and methods in the current Editor file in a |
| 76 | tree structure. In the shell, open a module first. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 77 | |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 78 | Path Browser |
| 79 | Show sys.path directories, modules, functions, classes and methods in a |
| 80 | tree structure. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 81 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 82 | Save |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 83 | Save the current window to the associated file, if there is one. Windows |
| 84 | that have been changed since being opened or last saved have a \* before |
| 85 | and after the window title. If there is no associated file, |
| 86 | do Save As instead. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 87 | |
| 88 | Save As... |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 89 | Save the current window with a Save As dialog. The file saved becomes the |
| 90 | new associated file for the window. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 91 | |
| 92 | Save Copy As... |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 93 | Save the current window to different file without changing the associated |
| 94 | file. |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 95 | |
| 96 | Print Window |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 97 | Print the current window to the default printer. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 98 | |
| 99 | Close |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 100 | Close the current window (ask to save if unsaved). |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 101 | |
| 102 | Exit |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 103 | Close all windows and quit IDLE (ask to save unsaved windows). |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 104 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 105 | Edit menu (Shell and Editor) |
| 106 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 107 | |
| 108 | Undo |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 109 | Undo the last change to the current window. A maximum of 1000 changes may |
| 110 | be undone. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 111 | |
| 112 | Redo |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 113 | Redo the last undone change to the current window. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 114 | |
| 115 | Cut |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 116 | Copy selection into the system-wide clipboard; then delete the selection. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 117 | |
| 118 | Copy |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 119 | Copy selection into the system-wide clipboard. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 120 | |
| 121 | Paste |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 122 | Insert contents of the system-wide clipboard into the current window. |
| 123 | |
| 124 | The clipboard functions are also available in context menus. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 125 | |
| 126 | Select All |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 127 | Select the entire contents of the current window. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 128 | |
| 129 | Find... |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 130 | Open a search dialog with many options |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 131 | |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 132 | Find Again |
| 133 | Repeat the last search, if there is one. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 134 | |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 135 | Find Selection |
| 136 | Search for the currently selected string, if there is one. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 137 | |
| 138 | Find in Files... |
Serhiy Storchaka | 6a7b3a7 | 2016-04-17 08:32:47 +0300 | [diff] [blame] | 139 | Open a file search dialog. Put results in a new output window. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 140 | |
| 141 | Replace... |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 142 | Open a search-and-replace dialog. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 143 | |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 144 | Go to Line |
| 145 | Move cursor to the line number requested and make that line visible. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 146 | |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 147 | Show Completions |
| 148 | Open a scrollable list allowing selection of keywords and attributes. See |
Cheryl Sabella | 01421be | 2018-12-20 00:38:54 -0500 | [diff] [blame] | 149 | :ref:`Completions <completions>` in the Editing and navigation section below. |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 150 | |
| 151 | Expand Word |
| 152 | Expand a prefix you have typed to match a full word in the same window; |
| 153 | repeat to get a different expansion. |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 154 | |
| 155 | Show call tip |
| 156 | After an unclosed parenthesis for a function, open a small window with |
Cheryl Sabella | 01421be | 2018-12-20 00:38:54 -0500 | [diff] [blame] | 157 | function parameter hints. See :ref:`Calltips <calltips>` in the |
| 158 | Editing and navigation section below. |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 159 | |
| 160 | Show surrounding parens |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 161 | Highlight the surrounding parenthesis. |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 162 | |
Terry Jan Reedy | 292cd6e | 2018-12-20 06:06:29 -0500 | [diff] [blame] | 163 | .. _format-menu: |
| 164 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 165 | Format menu (Editor window only) |
Terry Jan Reedy | f568494 | 2014-12-04 00:54:59 -0500 | [diff] [blame] | 166 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 167 | |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 168 | Indent Region |
| 169 | Shift selected lines right by the indent width (default 4 spaces). |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 170 | |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 171 | Dedent Region |
| 172 | Shift selected lines left by the indent width (default 4 spaces). |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 173 | |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 174 | Comment Out Region |
| 175 | Insert ## in front of selected lines. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 176 | |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 177 | Uncomment Region |
| 178 | Remove leading # or ## from selected lines. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 179 | |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 180 | Tabify Region |
| 181 | Turn *leading* stretches of spaces into tabs. (Note: We recommend using |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 182 | 4 space blocks to indent Python code.) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 183 | |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 184 | Untabify Region |
| 185 | Turn *all* tabs into the correct number of spaces. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 186 | |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 187 | Toggle Tabs |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 188 | Open a dialog to switch between indenting with spaces and tabs. |
| 189 | |
| 190 | New Indent Width |
| 191 | Open a dialog to change indent width. The accepted default by the Python |
| 192 | community is 4 spaces. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 193 | |
| 194 | Format Paragraph |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 195 | Reformat the current blank-line-delimited paragraph in comment block or |
| 196 | multiline string or selected line in a string. All lines in the |
| 197 | paragraph will be formatted to less than N columns, where N defaults to 72. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 198 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 199 | Strip trailing whitespace |
Terry Jan Reedy | ff70289 | 2017-09-15 13:05:28 -0400 | [diff] [blame] | 200 | Remove trailing space and other whitespace characters after the last |
| 201 | non-whitespace character of a line by applying str.rstrip to each line, |
Terry Jan Reedy | 6bf644e | 2019-11-24 16:29:29 -0500 | [diff] [blame] | 202 | including lines within multiline strings. Except for Shell windows, |
| 203 | remove extra newlines at the end of the file. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 204 | |
| 205 | .. index:: |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 206 | single: Run script |
| 207 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 208 | Run menu (Editor window only) |
| 209 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 210 | |
Cheryl Sabella | 201bc2d | 2019-06-17 22:24:10 -0400 | [diff] [blame] | 211 | .. _run-module: |
| 212 | |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 213 | Run Module |
Cheryl Sabella | 201bc2d | 2019-06-17 22:24:10 -0400 | [diff] [blame] | 214 | Do :ref:`Check Module <check-module>`. If no error, restart the shell to clean the |
Terry Jan Reedy | 8b5a981 | 2015-09-24 01:39:30 -0400 | [diff] [blame] | 215 | environment, then execute the module. Output is displayed in the Shell |
| 216 | window. Note that output requires use of ``print`` or ``write``. |
| 217 | When execution is complete, the Shell retains focus and displays a prompt. |
| 218 | At this point, one may interactively explore the result of execution. |
| 219 | This is similar to executing a file with ``python -i file`` at a command |
| 220 | line. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 221 | |
Cheryl Sabella | 201bc2d | 2019-06-17 22:24:10 -0400 | [diff] [blame] | 222 | .. _run-custom: |
| 223 | |
| 224 | Run... Customized |
| 225 | Same as :ref:`Run Module <run-module>`, but run the module with customized |
| 226 | settings. *Command Line Arguments* extend :data:`sys.argv` as if passed |
| 227 | on a command line. The module can be run in the Shell without restarting. |
| 228 | |
Terry Jan Reedy | 1407029 | 2019-08-04 16:45:15 -0400 | [diff] [blame] | 229 | .. _check-module: |
| 230 | |
| 231 | Check Module |
| 232 | Check the syntax of the module currently open in the Editor window. If the |
| 233 | module has not been saved IDLE will either prompt the user to save or |
| 234 | autosave, as selected in the General tab of the Idle Settings dialog. If |
| 235 | there is a syntax error, the approximate location is indicated in the |
| 236 | Editor window. |
| 237 | |
| 238 | .. _python-shell: |
| 239 | |
| 240 | Python Shell |
| 241 | Open or wake up the Python Shell window. |
| 242 | |
Cheryl Sabella | 201bc2d | 2019-06-17 22:24:10 -0400 | [diff] [blame] | 243 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 244 | Shell menu (Shell window only) |
| 245 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Ned Deily | 2778d0d | 2012-10-20 13:25:34 -0700 | [diff] [blame] | 246 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 247 | View Last Restart |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 248 | Scroll the shell window to the last Shell restart. |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 249 | |
| 250 | Restart Shell |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 251 | Restart the shell to clean the environment. |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 252 | |
Cheryl Sabella | c0381aa | 2018-12-28 15:11:30 -0500 | [diff] [blame] | 253 | Previous History |
| 254 | Cycle through earlier commands in history which match the current entry. |
| 255 | |
| 256 | Next History |
| 257 | Cycle through later commands in history which match the current entry. |
| 258 | |
Terry Jan Reedy | 4b73676 | 2016-09-12 01:50:03 -0400 | [diff] [blame] | 259 | Interrupt Execution |
| 260 | Stop a running program. |
| 261 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 262 | Debug menu (Shell window only) |
| 263 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 264 | |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 265 | Go to File/Line |
| 266 | Look on the current line. with the cursor, and the line above for a filename |
| 267 | and line number. If found, open the file if not already open, and show the |
| 268 | line. Use this to view source lines referenced in an exception traceback |
| 269 | and lines found by Find in Files. Also available in the context menu of |
| 270 | the Shell window and Output windows. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 271 | |
| 272 | .. index:: |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 273 | single: debugger |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 274 | single: stack viewer |
| 275 | |
| 276 | Debugger (toggle) |
csabella | 9dc2b38 | 2017-04-29 18:28:36 -0400 | [diff] [blame] | 277 | When activated, code entered in the Shell or run from an Editor will run |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 278 | under the debugger. In the Editor, breakpoints can be set with the context |
| 279 | menu. This feature is still incomplete and somewhat experimental. |
| 280 | |
| 281 | Stack Viewer |
| 282 | Show the stack traceback of the last exception in a tree widget, with |
| 283 | access to locals and globals. |
| 284 | |
| 285 | Auto-open Stack Viewer |
| 286 | Toggle automatically opening the stack viewer on an unhandled exception. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 287 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 288 | Options menu (Shell and Editor) |
| 289 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 290 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 291 | Configure IDLE |
Terry Jan Reedy | 93f3542 | 2015-10-13 22:03:51 -0400 | [diff] [blame] | 292 | Open a configuration dialog and change preferences for the following: |
| 293 | fonts, indentation, keybindings, text color themes, startup windows and |
Tal Einat | 7123ea0 | 2019-07-23 15:22:11 +0300 | [diff] [blame] | 294 | size, additional help sources, and extensions. On macOS, open the |
Terry Jan Reedy | 292cd6e | 2018-12-20 06:06:29 -0500 | [diff] [blame] | 295 | configuration dialog by selecting Preferences in the application |
Tal Einat | 7123ea0 | 2019-07-23 15:22:11 +0300 | [diff] [blame] | 296 | menu. For more details, see |
Terry Jan Reedy | 292cd6e | 2018-12-20 06:06:29 -0500 | [diff] [blame] | 297 | :ref:`Setting preferences <preferences>` under Help and preferences. |
Terry Jan Reedy | bb37b4c | 2014-12-04 01:26:04 -0500 | [diff] [blame] | 298 | |
Terry Jan Reedy | 1407029 | 2019-08-04 16:45:15 -0400 | [diff] [blame] | 299 | Most configuration options apply to all windows or all future windows. |
| 300 | The option items below only apply to the active window. |
Tal Einat | 7123ea0 | 2019-07-23 15:22:11 +0300 | [diff] [blame] | 301 | |
Cheryl Sabella | c1b4b0f | 2018-12-22 01:25:45 -0500 | [diff] [blame] | 302 | Show/Hide Code Context (Editor Window only) |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 303 | Open a pane at the top of the edit window which shows the block context |
Cheryl Sabella | 01421be | 2018-12-20 00:38:54 -0500 | [diff] [blame] | 304 | of the code which has scrolled above the top of the window. See |
Tal Einat | 7123ea0 | 2019-07-23 15:22:11 +0300 | [diff] [blame] | 305 | :ref:`Code Context <code-context>` in the Editing and Navigation section |
| 306 | below. |
| 307 | |
| 308 | Show/Hide Line Numbers (Editor Window only) |
| 309 | Open a column to the left of the edit window which shows the number |
| 310 | of each line of text. The default is off, which may be changed in the |
| 311 | preferences (see :ref:`Setting preferences <preferences>`). |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 312 | |
Terry Jan Reedy | df9b032 | 2019-05-27 19:16:46 -0400 | [diff] [blame] | 313 | Zoom/Restore Height |
| 314 | Toggles the window between normal size and maximum height. The initial size |
| 315 | defaults to 40 lines by 80 chars unless changed on the General tab of the |
Tal Einat | 5bff3c8 | 2019-06-17 22:41:00 +0300 | [diff] [blame] | 316 | Configure IDLE dialog. The maximum height for a screen is determined by |
| 317 | momentarily maximizing a window the first time one is zoomed on the screen. |
Tal Einat | 7123ea0 | 2019-07-23 15:22:11 +0300 | [diff] [blame] | 318 | Changing screen settings may invalidate the saved height. This toggle has |
Tal Einat | 5bff3c8 | 2019-06-17 22:41:00 +0300 | [diff] [blame] | 319 | no effect when a window is maximized. |
Terry Jan Reedy | df9b032 | 2019-05-27 19:16:46 -0400 | [diff] [blame] | 320 | |
Ned Deily | ccb416f | 2015-01-17 21:06:27 -0800 | [diff] [blame] | 321 | Window menu (Shell and Editor) |
| 322 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 323 | |
Cheryl Sabella | c1b4b0f | 2018-12-22 01:25:45 -0500 | [diff] [blame] | 324 | Lists the names of all open windows; select one to bring it to the foreground |
| 325 | (deiconifying it if necessary). |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 326 | |
| 327 | Help menu (Shell and Editor) |
| 328 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 329 | |
| 330 | About IDLE |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 331 | Display version, copyright, license, credits, and more. |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 332 | |
| 333 | IDLE Help |
Terry Jan Reedy | 1803263 | 2018-10-28 16:21:18 -0400 | [diff] [blame] | 334 | Display this IDLE document, detailing the menu options, basic editing and |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 335 | navigation, and other tips. |
| 336 | |
| 337 | Python Docs |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 338 | Access local Python documentation, if installed, or start a web browser |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 339 | and open docs.python.org showing the latest Python documentation. |
| 340 | |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 341 | Turtle Demo |
Andrés Delfino | 271818f | 2018-09-14 14:13:09 -0300 | [diff] [blame] | 342 | Run the turtledemo module with example Python code and turtle drawings. |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 343 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 344 | Additional help sources may be added here with the Configure IDLE dialog under |
Cheryl Sabella | 01421be | 2018-12-20 00:38:54 -0500 | [diff] [blame] | 345 | the General tab. See the :ref:`Help sources <help-sources>` subsection below |
| 346 | for more on Help menu choices. |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 347 | |
Terry Jan Reedy | f568494 | 2014-12-04 00:54:59 -0500 | [diff] [blame] | 348 | .. index:: |
| 349 | single: Cut |
| 350 | single: Copy |
| 351 | single: Paste |
| 352 | single: Set Breakpoint |
| 353 | single: Clear Breakpoint |
| 354 | single: breakpoints |
| 355 | |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 356 | Context Menus |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 357 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 358 | |
Terry Jan Reedy | b65413b | 2018-11-15 13:15:13 -0500 | [diff] [blame] | 359 | Open a context menu by right-clicking in a window (Control-click on macOS). |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 360 | Context menus have the standard clipboard functions also on the Edit menu. |
Ned Deily | 2778d0d | 2012-10-20 13:25:34 -0700 | [diff] [blame] | 361 | |
Andrew Svetlov | d183767 | 2012-11-01 22:41:19 +0200 | [diff] [blame] | 362 | Cut |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 363 | Copy selection into the system-wide clipboard; then delete the selection. |
Andrew Svetlov | d183767 | 2012-11-01 22:41:19 +0200 | [diff] [blame] | 364 | |
| 365 | Copy |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 366 | Copy selection into the system-wide clipboard. |
Andrew Svetlov | d183767 | 2012-11-01 22:41:19 +0200 | [diff] [blame] | 367 | |
| 368 | Paste |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 369 | Insert contents of the system-wide clipboard into the current window. |
| 370 | |
| 371 | Editor windows also have breakpoint functions. Lines with a breakpoint set are |
| 372 | specially marked. Breakpoints only have an effect when running under the |
Tal Einat | d6c08db | 2020-01-06 01:51:48 +0200 | [diff] [blame] | 373 | debugger. Breakpoints for a file are saved in the user's ``.idlerc`` |
| 374 | directory. |
Andrew Svetlov | d183767 | 2012-11-01 22:41:19 +0200 | [diff] [blame] | 375 | |
Ned Deily | 2778d0d | 2012-10-20 13:25:34 -0700 | [diff] [blame] | 376 | Set Breakpoint |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 377 | Set a breakpoint on the current line. |
Ned Deily | 2778d0d | 2012-10-20 13:25:34 -0700 | [diff] [blame] | 378 | |
| 379 | Clear Breakpoint |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 380 | Clear the breakpoint on that line. |
Ned Deily | 2778d0d | 2012-10-20 13:25:34 -0700 | [diff] [blame] | 381 | |
Terry Jan Reedy | 68d6dc0 | 2018-10-28 12:44:44 -0400 | [diff] [blame] | 382 | Shell and Output windows also have the following. |
Andrew Svetlov | d183767 | 2012-11-01 22:41:19 +0200 | [diff] [blame] | 383 | |
Ned Deily | 2778d0d | 2012-10-20 13:25:34 -0700 | [diff] [blame] | 384 | Go to file/line |
| 385 | Same as in Debug menu. |
| 386 | |
Benjamin Peterson | 577277f | 2019-03-25 21:46:35 -0700 | [diff] [blame] | 387 | The Shell window also has an output squeezing facility explained in the *Python |
| 388 | Shell window* subsection below. |
Terry Jan Reedy | 68d6dc0 | 2018-10-28 12:44:44 -0400 | [diff] [blame] | 389 | |
| 390 | Squeeze |
| 391 | If the cursor is over an output line, squeeze all the output between |
| 392 | the code above and the prompt below down to a 'Squeezed text' label. |
| 393 | |
Ned Deily | 2778d0d | 2012-10-20 13:25:34 -0700 | [diff] [blame] | 394 | |
Cheryl Sabella | 01421be | 2018-12-20 00:38:54 -0500 | [diff] [blame] | 395 | .. _editing-and-navigation: |
| 396 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 397 | Editing and navigation |
| 398 | ---------------------- |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 399 | |
Terry Jan Reedy | ea9c8bd | 2018-10-28 20:42:18 -0400 | [diff] [blame] | 400 | Editor windows |
| 401 | ^^^^^^^^^^^^^^ |
| 402 | |
| 403 | IDLE may open editor windows when it starts, depending on settings |
| 404 | and how you start IDLE. Thereafter, use the File menu. There can be only |
| 405 | one open editor window for a given file. |
| 406 | |
| 407 | The title bar contains the name of the file, the full path, and the version |
| 408 | of Python and IDLE running the window. The status bar contains the line |
| 409 | number ('Ln') and column number ('Col'). Line numbers start with 1; |
| 410 | column numbers with 0. |
| 411 | |
| 412 | IDLE assumes that files with a known .py* extension contain Python code |
| 413 | and that other files do not. Run Python code with the Run menu. |
| 414 | |
| 415 | Key bindings |
| 416 | ^^^^^^^^^^^^ |
| 417 | |
Serhiy Storchaka | 0424eaf | 2015-09-12 17:45:25 +0300 | [diff] [blame] | 418 | In this section, 'C' refers to the :kbd:`Control` key on Windows and Unix and |
Terry Jan Reedy | b65413b | 2018-11-15 13:15:13 -0500 | [diff] [blame] | 419 | the :kbd:`Command` key on macOS. |
Terry Jan Reedy | f568494 | 2014-12-04 00:54:59 -0500 | [diff] [blame] | 420 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 421 | * :kbd:`Backspace` deletes to the left; :kbd:`Del` deletes to the right |
| 422 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 423 | * :kbd:`C-Backspace` delete word left; :kbd:`C-Del` delete word to the right |
| 424 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 425 | * Arrow keys and :kbd:`Page Up`/:kbd:`Page Down` to move around |
| 426 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 427 | * :kbd:`C-LeftArrow` and :kbd:`C-RightArrow` moves by words |
| 428 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 429 | * :kbd:`Home`/:kbd:`End` go to begin/end of line |
| 430 | |
| 431 | * :kbd:`C-Home`/:kbd:`C-End` go to begin/end of file |
| 432 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 433 | * Some useful Emacs bindings are inherited from Tcl/Tk: |
| 434 | |
| 435 | * :kbd:`C-a` beginning of line |
| 436 | |
| 437 | * :kbd:`C-e` end of line |
| 438 | |
| 439 | * :kbd:`C-k` kill line (but doesn't put it in clipboard) |
| 440 | |
| 441 | * :kbd:`C-l` center window around the insertion point |
| 442 | |
csabella | 9dc2b38 | 2017-04-29 18:28:36 -0400 | [diff] [blame] | 443 | * :kbd:`C-b` go backward one character without deleting (usually you can |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 444 | also use the cursor key for this) |
| 445 | |
| 446 | * :kbd:`C-f` go forward one character without deleting (usually you can |
| 447 | also use the cursor key for this) |
| 448 | |
| 449 | * :kbd:`C-p` go up one line (usually you can also use the cursor key for |
| 450 | this) |
| 451 | |
| 452 | * :kbd:`C-d` delete next character |
| 453 | |
| 454 | Standard keybindings (like :kbd:`C-c` to copy and :kbd:`C-v` to paste) |
| 455 | may work. Keybindings are selected in the Configure IDLE dialog. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 456 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 457 | Automatic indentation |
| 458 | ^^^^^^^^^^^^^^^^^^^^^ |
| 459 | |
| 460 | After a block-opening statement, the next line is indented by 4 spaces (in the |
| 461 | Python Shell window by one tab). After certain keywords (break, return etc.) |
| 462 | the next line is dedented. In leading indentation, :kbd:`Backspace` deletes up |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 463 | to 4 spaces if they are there. :kbd:`Tab` inserts spaces (in the Python |
csabella | 9dc2b38 | 2017-04-29 18:28:36 -0400 | [diff] [blame] | 464 | Shell window one tab), number depends on Indent width. Currently, tabs |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 465 | are restricted to four spaces due to Tcl/Tk limitations. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 466 | |
Terry Jan Reedy | 292cd6e | 2018-12-20 06:06:29 -0500 | [diff] [blame] | 467 | See also the indent/dedent region commands on the |
| 468 | :ref:`Format menu <format-menu>`. |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 469 | |
Cheryl Sabella | 01421be | 2018-12-20 00:38:54 -0500 | [diff] [blame] | 470 | |
| 471 | .. _completions: |
| 472 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 473 | Completions |
| 474 | ^^^^^^^^^^^ |
| 475 | |
| 476 | Completions are supplied for functions, classes, and attributes of classes, |
| 477 | both built-in and user-defined. Completions are also provided for |
| 478 | filenames. |
| 479 | |
| 480 | The AutoCompleteWindow (ACW) will open after a predefined delay (default is |
| 481 | two seconds) after a '.' or (in a string) an os.sep is typed. If after one |
| 482 | of those characters (plus zero or more other characters) a tab is typed |
| 483 | the ACW will open immediately if a possible continuation is found. |
| 484 | |
| 485 | If there is only one possible completion for the characters entered, a |
| 486 | :kbd:`Tab` will supply that completion without opening the ACW. |
| 487 | |
| 488 | 'Show Completions' will force open a completions window, by default the |
| 489 | :kbd:`C-space` will open a completions window. In an empty |
| 490 | string, this will contain the files in the current directory. On a |
| 491 | blank line, it will contain the built-in and user-defined functions and |
csabella | 9dc2b38 | 2017-04-29 18:28:36 -0400 | [diff] [blame] | 492 | classes in the current namespaces, plus any modules imported. If some |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 493 | characters have been entered, the ACW will attempt to be more specific. |
| 494 | |
| 495 | If a string of characters is typed, the ACW selection will jump to the |
| 496 | entry most closely matching those characters. Entering a :kbd:`tab` will |
| 497 | cause the longest non-ambiguous match to be entered in the Editor window or |
| 498 | Shell. Two :kbd:`tab` in a row will supply the current ACW selection, as |
| 499 | will return or a double click. Cursor keys, Page Up/Down, mouse selection, |
| 500 | and the scroll wheel all operate on the ACW. |
| 501 | |
| 502 | "Hidden" attributes can be accessed by typing the beginning of hidden |
| 503 | name after a '.', e.g. '_'. This allows access to modules with |
| 504 | ``__all__`` set, or to class-private attributes. |
| 505 | |
| 506 | Completions and the 'Expand Word' facility can save a lot of typing! |
| 507 | |
| 508 | Completions are currently limited to those in the namespaces. Names in |
| 509 | an Editor window which are not via ``__main__`` and :data:`sys.modules` will |
| 510 | not be found. Run the module once with your imports to correct this situation. |
| 511 | Note that IDLE itself places quite a few modules in sys.modules, so |
| 512 | much can be found by default, e.g. the re module. |
| 513 | |
| 514 | If you don't like the ACW popping up unbidden, simply make the delay |
Terry Jan Reedy | 37f8135 | 2015-09-29 01:55:57 -0400 | [diff] [blame] | 515 | longer or disable the extension. |
| 516 | |
Cheryl Sabella | 01421be | 2018-12-20 00:38:54 -0500 | [diff] [blame] | 517 | .. _calltips: |
| 518 | |
Terry Jan Reedy | 37f8135 | 2015-09-29 01:55:57 -0400 | [diff] [blame] | 519 | Calltips |
| 520 | ^^^^^^^^ |
| 521 | |
Alex Gaynor | 1cf2a80 | 2017-02-28 22:26:56 -0500 | [diff] [blame] | 522 | A calltip is shown when one types :kbd:`(` after the name of an *accessible* |
Terry Jan Reedy | 37f8135 | 2015-09-29 01:55:57 -0400 | [diff] [blame] | 523 | function. A name expression may include dots and subscripts. A calltip |
| 524 | remains until it is clicked, the cursor is moved out of the argument area, |
| 525 | or :kbd:`)` is typed. When the cursor is in the argument part of a definition, |
| 526 | the menu or shortcut display a calltip. |
| 527 | |
| 528 | A calltip consists of the function signature and the first line of the |
| 529 | docstring. For builtins without an accessible signature, the calltip |
| 530 | consists of all lines up the fifth line or the first blank line. These |
| 531 | details may change. |
| 532 | |
| 533 | The set of *accessible* functions depends on what modules have been imported |
| 534 | into the user process, including those imported by Idle itself, |
| 535 | and what definitions have been run, all since the last restart. |
| 536 | |
| 537 | For example, restart the Shell and enter ``itertools.count(``. A calltip |
| 538 | appears because Idle imports itertools into the user process for its own use. |
| 539 | (This could change.) Enter ``turtle.write(`` and nothing appears. Idle does |
| 540 | not import turtle. The menu or shortcut do nothing either. Enter |
| 541 | ``import turtle`` and then ``turtle.write(`` will work. |
| 542 | |
| 543 | In an editor, import statements have no effect until one runs the file. One |
| 544 | might want to run a file after writing the import statements at the top, |
| 545 | or immediately run an existing file before editing. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 546 | |
Cheryl Sabella | 01421be | 2018-12-20 00:38:54 -0500 | [diff] [blame] | 547 | .. _code-context: |
| 548 | |
| 549 | Code Context |
| 550 | ^^^^^^^^^^^^ |
| 551 | |
| 552 | Within an editor window containing Python code, code context can be toggled |
| 553 | in order to show or hide a pane at the top of the window. When shown, this |
| 554 | pane freezes the opening lines for block code, such as those beginning with |
| 555 | ``class``, ``def``, or ``if`` keywords, that would have otherwise scrolled |
| 556 | out of view. The size of the pane will be expanded and contracted as needed |
| 557 | to show the all current levels of context, up to the maximum number of |
| 558 | lines defined in the Configure IDLE dialog (which defaults to 15). If there |
| 559 | are no current context lines and the feature is toggled on, a single blank |
| 560 | line will display. Clicking on a line in the context pane will move that |
| 561 | line to the top of the editor. |
| 562 | |
| 563 | The text and background colors for the context pane can be configured under |
| 564 | the Highlights tab in the Configure IDLE dialog. |
| 565 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 566 | Python Shell window |
| 567 | ^^^^^^^^^^^^^^^^^^^ |
| 568 | |
Terry Jan Reedy | 75d9d59 | 2018-11-06 12:37:36 -0500 | [diff] [blame] | 569 | With IDLE's Shell, one enters, edits, and recalls complete statements. |
| 570 | Most consoles and terminals only work with a single physical line at a time. |
| 571 | |
| 572 | When one pastes code into Shell, it is not compiled and possibly executed |
| 573 | until one hits :kbd:`Return`. One may edit pasted code first. |
| 574 | If one pastes more that one statement into Shell, the result will be a |
| 575 | :exc:`SyntaxError` when multiple statements are compiled as if they were one. |
| 576 | |
| 577 | The editing features described in previous subsections work when entering |
| 578 | code interactively. IDLE's Shell window also responds to the following keys. |
Terry Jan Reedy | 68d6dc0 | 2018-10-28 12:44:44 -0400 | [diff] [blame] | 579 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 580 | * :kbd:`C-c` interrupts executing command |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 581 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 582 | * :kbd:`C-d` sends end-of-file; closes window if typed at a ``>>>`` prompt |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 583 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 584 | * :kbd:`Alt-/` (Expand word) is also useful to reduce typing |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 585 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 586 | Command history |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 587 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 588 | * :kbd:`Alt-p` retrieves previous command matching what you have typed. On |
Terry Jan Reedy | b65413b | 2018-11-15 13:15:13 -0500 | [diff] [blame] | 589 | macOS use :kbd:`C-p`. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 590 | |
Terry Jan Reedy | b65413b | 2018-11-15 13:15:13 -0500 | [diff] [blame] | 591 | * :kbd:`Alt-n` retrieves next. On macOS use :kbd:`C-n`. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 592 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 593 | * :kbd:`Return` while on any previous command retrieves that command |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 594 | |
Terry Jan Reedy | f660ce2 | 2015-09-24 23:13:49 -0400 | [diff] [blame] | 595 | Text colors |
| 596 | ^^^^^^^^^^^ |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 597 | |
Terry Jan Reedy | f660ce2 | 2015-09-24 23:13:49 -0400 | [diff] [blame] | 598 | Idle defaults to black on white text, but colors text with special meanings. |
| 599 | For the shell, these are shell output, shell error, user output, and |
| 600 | user error. For Python code, at the shell prompt or in an editor, these are |
| 601 | keywords, builtin class and function names, names following ``class`` and |
| 602 | ``def``, strings, and comments. For any text window, these are the cursor (when |
| 603 | present), found text (when possible), and selected text. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 604 | |
Terry Jan Reedy | f660ce2 | 2015-09-24 23:13:49 -0400 | [diff] [blame] | 605 | Text coloring is done in the background, so uncolorized text is occasionally |
| 606 | visible. To change the color scheme, use the Configure IDLE dialog |
| 607 | Highlighting tab. The marking of debugger breakpoint lines in the editor and |
| 608 | text in popups and dialogs is not user-configurable. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 609 | |
| 610 | |
Terry Jan Reedy | 0053c47 | 2015-09-24 03:09:43 -0400 | [diff] [blame] | 611 | Startup and code execution |
| 612 | -------------------------- |
Benjamin Peterson | f07d002 | 2009-03-21 17:31:58 +0000 | [diff] [blame] | 613 | |
| 614 | Upon startup with the ``-s`` option, IDLE will execute the file referenced by |
| 615 | the environment variables :envvar:`IDLESTARTUP` or :envvar:`PYTHONSTARTUP`. |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 616 | IDLE first checks for ``IDLESTARTUP``; if ``IDLESTARTUP`` is present the file |
| 617 | referenced is run. If ``IDLESTARTUP`` is not present, IDLE checks for |
Benjamin Peterson | f07d002 | 2009-03-21 17:31:58 +0000 | [diff] [blame] | 618 | ``PYTHONSTARTUP``. Files referenced by these environment variables are |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 619 | convenient places to store functions that are used frequently from the IDLE |
Benjamin Peterson | f07d002 | 2009-03-21 17:31:58 +0000 | [diff] [blame] | 620 | shell, or for executing import statements to import common modules. |
| 621 | |
| 622 | In addition, ``Tk`` also loads a startup file if it is present. Note that the |
| 623 | Tk file is loaded unconditionally. This additional file is ``.Idle.py`` and is |
| 624 | looked for in the user's home directory. Statements in this file will be |
Terry Jan Reedy | 3ab745e | 2014-12-05 02:43:07 -0500 | [diff] [blame] | 625 | executed in the Tk namespace, so this file is not useful for importing |
| 626 | functions to be used from IDLE's Python shell. |
Benjamin Peterson | f07d002 | 2009-03-21 17:31:58 +0000 | [diff] [blame] | 627 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 628 | Command line usage |
| 629 | ^^^^^^^^^^^^^^^^^^ |
| 630 | |
Martin Panter | 1050d2d | 2016-07-26 11:18:21 +0200 | [diff] [blame] | 631 | .. code-block:: none |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 632 | |
Terry Jan Reedy | 968e285 | 2015-09-23 03:52:23 -0400 | [diff] [blame] | 633 | idle.py [-c command] [-d] [-e] [-h] [-i] [-r file] [-s] [-t title] [-] [arg] ... |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 634 | |
Terry Jan Reedy | 968e285 | 2015-09-23 03:52:23 -0400 | [diff] [blame] | 635 | -c command run command in the shell window |
| 636 | -d enable debugger and open shell window |
| 637 | -e open editor window |
Terry Jan Reedy | 3399e1e | 2016-08-30 16:58:01 -0400 | [diff] [blame] | 638 | -h print help message with legal combinations and exit |
Terry Jan Reedy | 968e285 | 2015-09-23 03:52:23 -0400 | [diff] [blame] | 639 | -i open shell window |
| 640 | -r file run file in shell window |
| 641 | -s run $IDLESTARTUP or $PYTHONSTARTUP first, in shell window |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 642 | -t title set title of shell window |
Terry Jan Reedy | 968e285 | 2015-09-23 03:52:23 -0400 | [diff] [blame] | 643 | - run stdin in shell (- must be last option before args) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 644 | |
| 645 | If there are arguments: |
| 646 | |
Terry Jan Reedy | 968e285 | 2015-09-23 03:52:23 -0400 | [diff] [blame] | 647 | * If ``-``, ``-c``, or ``r`` is used, all arguments are placed in |
| 648 | ``sys.argv[1:...]`` and ``sys.argv[0]`` is set to ``''``, ``'-c'``, |
| 649 | or ``'-r'``. No editor window is opened, even if that is the default |
| 650 | set in the Options dialog. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 651 | |
Terry Jan Reedy | 968e285 | 2015-09-23 03:52:23 -0400 | [diff] [blame] | 652 | * Otherwise, arguments are files opened for editing and |
| 653 | ``sys.argv`` reflects the arguments passed to IDLE itself. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 654 | |
terryjreedy | 188aedf | 2017-06-13 21:32:16 -0400 | [diff] [blame] | 655 | Startup failure |
| 656 | ^^^^^^^^^^^^^^^ |
| 657 | |
| 658 | IDLE uses a socket to communicate between the IDLE GUI process and the user |
| 659 | code execution process. A connection must be established whenever the Shell |
| 660 | starts or restarts. (The latter is indicated by a divider line that says |
| 661 | 'RESTART'). If the user process fails to connect to the GUI process, it |
| 662 | displays a ``Tk`` error box with a 'cannot connect' message that directs the |
| 663 | user here. It then exits. |
| 664 | |
| 665 | A common cause of failure is a user-written file with the same name as a |
| 666 | standard library module, such as *random.py* and *tkinter.py*. When such a |
| 667 | file is located in the same directory as a file that is about to be run, |
| 668 | IDLE cannot import the stdlib file. The current fix is to rename the |
| 669 | user file. |
| 670 | |
| 671 | Though less common than in the past, an antivirus or firewall program may |
| 672 | stop the connection. If the program cannot be taught to allow the |
| 673 | connection, then it must be turned off for IDLE to work. It is safe to |
| 674 | allow this internal connection because no data is visible on external |
| 675 | ports. A similar problem is a network mis-configuration that blocks |
| 676 | connections. |
| 677 | |
| 678 | Python installation issues occasionally stop IDLE: multiple versions can |
| 679 | clash, or a single installation might need admin access. If one undo the |
| 680 | clash, or cannot or does not want to run as admin, it might be easiest to |
| 681 | completely remove Python and start over. |
| 682 | |
| 683 | A zombie pythonw.exe process could be a problem. On Windows, use Task |
| 684 | Manager to detect and stop one. Sometimes a restart initiated by a program |
| 685 | crash or Keyboard Interrupt (control-C) may fail to connect. Dismissing |
| 686 | the error box or Restart Shell on the Shell menu may fix a temporary problem. |
| 687 | |
| 688 | When IDLE first starts, it attempts to read user configuration files in |
Tal Einat | d6c08db | 2020-01-06 01:51:48 +0200 | [diff] [blame] | 689 | ``~/.idlerc/`` (~ is one's home directory). If there is a problem, an error |
terryjreedy | 188aedf | 2017-06-13 21:32:16 -0400 | [diff] [blame] | 690 | message should be displayed. Leaving aside random disk glitches, this can |
| 691 | be prevented by never editing the files by hand, using the configuration |
| 692 | dialog, under Options, instead Options. Once it happens, the solution may |
| 693 | be to delete one or more of the configuration files. |
| 694 | |
| 695 | If IDLE quits with no message, and it was not started from a console, try |
Tal Einat | d6c08db | 2020-01-06 01:51:48 +0200 | [diff] [blame] | 696 | starting from a console (``python -m idlelib``) and see if a message appears. |
terryjreedy | 188aedf | 2017-06-13 21:32:16 -0400 | [diff] [blame] | 697 | |
Terry Jan Reedy | 5e79090 | 2018-11-05 21:30:32 -0500 | [diff] [blame] | 698 | Running user code |
| 699 | ^^^^^^^^^^^^^^^^^ |
Terry Jan Reedy | 0053c47 | 2015-09-24 03:09:43 -0400 | [diff] [blame] | 700 | |
Terry Jan Reedy | 98758bc | 2017-09-12 09:05:16 -0400 | [diff] [blame] | 701 | With rare exceptions, the result of executing Python code with IDLE is |
Terry Jan Reedy | 5e79090 | 2018-11-05 21:30:32 -0500 | [diff] [blame] | 702 | intended to be the same as executing the same code by the default method, |
| 703 | directly with Python in a text-mode system console or terminal window. |
Terry Jan Reedy | 98758bc | 2017-09-12 09:05:16 -0400 | [diff] [blame] | 704 | However, the different interface and operation occasionally affect |
Terry Jan Reedy | 5e79090 | 2018-11-05 21:30:32 -0500 | [diff] [blame] | 705 | visible results. For instance, ``sys.modules`` starts with more entries, |
| 706 | and ``threading.activeCount()`` returns 2 instead of 1. |
Terry Jan Reedy | 0053c47 | 2015-09-24 03:09:43 -0400 | [diff] [blame] | 707 | |
Terry Jan Reedy | 5e79090 | 2018-11-05 21:30:32 -0500 | [diff] [blame] | 708 | By default, IDLE runs user code in a separate OS process rather than in |
| 709 | the user interface process that runs the shell and editor. In the execution |
| 710 | process, it replaces ``sys.stdin``, ``sys.stdout``, and ``sys.stderr`` |
| 711 | with objects that get input from and send output to the Shell window. |
| 712 | The original values stored in ``sys.__stdin__``, ``sys.__stdout__``, and |
| 713 | ``sys.__stderr__`` are not touched, but may be ``None``. |
| 714 | |
Terry Jan Reedy | 98758bc | 2017-09-12 09:05:16 -0400 | [diff] [blame] | 715 | When Shell has the focus, it controls the keyboard and screen. This is |
| 716 | normally transparent, but functions that directly access the keyboard |
Terry Jan Reedy | 5e79090 | 2018-11-05 21:30:32 -0500 | [diff] [blame] | 717 | and screen will not work. These include system-specific functions that |
| 718 | determine whether a key has been pressed and if so, which. |
Terry Jan Reedy | 0053c47 | 2015-09-24 03:09:43 -0400 | [diff] [blame] | 719 | |
Terry Jan Reedy | 5e79090 | 2018-11-05 21:30:32 -0500 | [diff] [blame] | 720 | IDLE's standard stream replacements are not inherited by subprocesses |
| 721 | created in the execution process, whether directly by user code or by modules |
| 722 | such as multiprocessing. If such subprocess use ``input`` from sys.stdin |
| 723 | or ``print`` or ``write`` to sys.stdout or sys.stderr, |
| 724 | IDLE should be started in a command line window. The secondary subprocess |
| 725 | will then be attached to that window for input and output. |
| 726 | |
Tal Einat | fcf1d00 | 2019-07-06 15:35:24 +0300 | [diff] [blame] | 727 | The IDLE code running in the execution process adds frames to the call stack |
| 728 | that would not be there otherwise. IDLE wraps ``sys.getrecursionlimit`` and |
| 729 | ``sys.setrecursionlimit`` to reduce the effect of the additional stack frames. |
| 730 | |
Terry Jan Reedy | 5e79090 | 2018-11-05 21:30:32 -0500 | [diff] [blame] | 731 | If ``sys`` is reset by user code, such as with ``importlib.reload(sys)``, |
| 732 | IDLE's changes are lost and input from the keyboard and output to the screen |
| 733 | will not work correctly. |
Terry Jan Reedy | 0053c47 | 2015-09-24 03:09:43 -0400 | [diff] [blame] | 734 | |
Terry Jan Reedy | 6d965b3 | 2019-05-19 22:52:22 -0400 | [diff] [blame] | 735 | When user code raises SystemExit either directly or by calling sys.exit, IDLE |
| 736 | returns to a Shell prompt instead of exiting. |
| 737 | |
Terry Jan Reedy | 75d9d59 | 2018-11-06 12:37:36 -0500 | [diff] [blame] | 738 | User output in Shell |
| 739 | ^^^^^^^^^^^^^^^^^^^^ |
| 740 | |
| 741 | When a program outputs text, the result is determined by the |
| 742 | corresponding output device. When IDLE executes user code, ``sys.stdout`` |
| 743 | and ``sys.stderr`` are connected to the display area of IDLE's Shell. Some of |
| 744 | its features are inherited from the underlying Tk Text widget. Others |
Terry Jan Reedy | 76cd0c3 | 2018-11-06 23:55:06 -0500 | [diff] [blame] | 745 | are programmed additions. Where it matters, Shell is designed for development |
| 746 | rather than production runs. |
| 747 | |
| 748 | For instance, Shell never throws away output. A program that sends unlimited |
| 749 | output to Shell will eventually fill memory, resulting in a memory error. |
| 750 | In contrast, some system text windows only keep the last n lines of output. |
| 751 | A Windows console, for instance, keeps a user-settable 1 to 9999 lines, |
| 752 | with 300 the default. |
Terry Jan Reedy | 75d9d59 | 2018-11-06 12:37:36 -0500 | [diff] [blame] | 753 | |
Benjamin Peterson | 577277f | 2019-03-25 21:46:35 -0700 | [diff] [blame] | 754 | A Tk Text widget, and hence IDLE's Shell, displays characters (codepoints) in |
| 755 | the BMP (Basic Multilingual Plane) subset of Unicode. Which characters are |
| 756 | displayed with a proper glyph and which with a replacement box depends on the |
| 757 | operating system and installed fonts. Tab characters cause the following text |
| 758 | to begin after the next tab stop. (They occur every 8 'characters'). Newline |
| 759 | characters cause following text to appear on a new line. Other control |
| 760 | characters are ignored or displayed as a space, box, or something else, |
| 761 | depending on the operating system and font. (Moving the text cursor through |
Terry Jan Reedy | 55d0351 | 2019-04-26 23:22:36 -0400 | [diff] [blame] | 762 | such output with arrow keys may exhibit some surprising spacing behavior.) :: |
Terry Jan Reedy | 8a03ff2 | 2019-02-08 22:51:51 -0500 | [diff] [blame] | 763 | |
Terry Jan Reedy | 55d0351 | 2019-04-26 23:22:36 -0400 | [diff] [blame] | 764 | >>> s = 'a\tb\a<\x02><\r>\bc\nd' # Enter 22 chars. |
Terry Jan Reedy | 8a03ff2 | 2019-02-08 22:51:51 -0500 | [diff] [blame] | 765 | >>> len(s) |
| 766 | 14 |
| 767 | >>> s # Display repr(s) |
| 768 | 'a\tb\x07<\x02><\r>\x08c\nd' |
| 769 | >>> print(s, end='') # Display s as is. |
| 770 | # Result varies by OS and font. Try it. |
| 771 | |
| 772 | The ``repr`` function is used for interactive echo of expression |
| 773 | values. It returns an altered version of the input string in which |
| 774 | control codes, some BMP codepoints, and all non-BMP codepoints are |
| 775 | replaced with escape codes. As demonstrated above, it allows one to |
| 776 | identify the characters in a string, regardless of how they are displayed. |
Terry Jan Reedy | 75d9d59 | 2018-11-06 12:37:36 -0500 | [diff] [blame] | 777 | |
| 778 | Normal and error output are generally kept separate (on separate lines) |
| 779 | from code input and each other. They each get different highlight colors. |
| 780 | |
| 781 | For SyntaxError tracebacks, the normal '^' marking where the error was |
| 782 | detected is replaced by coloring the text with an error highlight. |
| 783 | When code run from a file causes other exceptions, one may right click |
| 784 | on a traceback line to jump to the corresponding line in an IDLE editor. |
| 785 | The file will be opened if necessary. |
| 786 | |
| 787 | Shell has a special facility for squeezing output lines down to a |
| 788 | 'Squeezed text' label. This is done automatically |
| 789 | for output over N lines (N = 50 by default). |
| 790 | N can be changed in the PyShell section of the General |
| 791 | page of the Settings dialog. Output with fewer lines can be squeezed by |
| 792 | right clicking on the output. This can be useful lines long enough to slow |
| 793 | down scrolling. |
| 794 | |
| 795 | Squeezed output is expanded in place by double-clicking the label. |
| 796 | It can also be sent to the clipboard or a separate view window by |
| 797 | right-clicking the label. |
| 798 | |
Terry Jan Reedy | 98758bc | 2017-09-12 09:05:16 -0400 | [diff] [blame] | 799 | Developing tkinter applications |
| 800 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 801 | |
| 802 | IDLE is intentionally different from standard Python in order to |
| 803 | facilitate development of tkinter programs. Enter ``import tkinter as tk; |
| 804 | root = tk.Tk()`` in standard Python and nothing appears. Enter the same |
| 805 | in IDLE and a tk window appears. In standard Python, one must also enter |
| 806 | ``root.update()`` to see the window. IDLE does the equivalent in the |
Terry Jan Reedy | 8a533ff | 2019-05-16 01:20:37 -0400 | [diff] [blame] | 807 | background, about 20 times a second, which is about every 50 milliseconds. |
Terry Jan Reedy | 98758bc | 2017-09-12 09:05:16 -0400 | [diff] [blame] | 808 | Next enter ``b = tk.Button(root, text='button'); b.pack()``. Again, |
| 809 | nothing visibly changes in standard Python until one enters ``root.update()``. |
| 810 | |
| 811 | Most tkinter programs run ``root.mainloop()``, which usually does not |
| 812 | return until the tk app is destroyed. If the program is run with |
| 813 | ``python -i`` or from an IDLE editor, a ``>>>`` shell prompt does not |
| 814 | appear until ``mainloop()`` returns, at which time there is nothing left |
| 815 | to interact with. |
| 816 | |
| 817 | When running a tkinter program from an IDLE editor, one can comment out |
| 818 | the mainloop call. One then gets a shell prompt immediately and can |
| 819 | interact with the live application. One just has to remember to |
| 820 | re-enable the mainloop call when running in standard Python. |
| 821 | |
Terry Jan Reedy | f568494 | 2014-12-04 00:54:59 -0500 | [diff] [blame] | 822 | Running without a subprocess |
| 823 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 824 | |
Terry Jan Reedy | 0053c47 | 2015-09-24 03:09:43 -0400 | [diff] [blame] | 825 | By default, IDLE executes user code in a separate subprocess via a socket, |
Terry Jan Reedy | 6e10ec5 | 2015-09-23 20:00:33 -0400 | [diff] [blame] | 826 | which uses the internal loopback interface. This connection is not |
| 827 | externally visible and no data is sent to or received from the Internet. |
| 828 | If firewall software complains anyway, you can ignore it. |
| 829 | |
| 830 | If the attempt to make the socket connection fails, Idle will notify you. |
| 831 | Such failures are sometimes transient, but if persistent, the problem |
csabella | 9dc2b38 | 2017-04-29 18:28:36 -0400 | [diff] [blame] | 832 | may be either a firewall blocking the connection or misconfiguration of |
Terry Jan Reedy | 6e10ec5 | 2015-09-23 20:00:33 -0400 | [diff] [blame] | 833 | a particular system. Until the problem is fixed, one can run Idle with |
| 834 | the -n command line switch. |
| 835 | |
Terry Jan Reedy | f568494 | 2014-12-04 00:54:59 -0500 | [diff] [blame] | 836 | If IDLE is started with the -n command line switch it will run in a |
| 837 | single process and will not create the subprocess which runs the RPC |
| 838 | Python execution server. This can be useful if Python cannot create |
| 839 | the subprocess or the RPC socket interface on your platform. However, |
| 840 | in this mode user code is not isolated from IDLE itself. Also, the |
| 841 | environment is not restarted when Run/Run Module (F5) is selected. If |
| 842 | your code has been modified, you must reload() the affected modules and |
| 843 | re-import any specific items (e.g. from foo import baz) if the changes |
| 844 | are to take effect. For these reasons, it is preferable to run IDLE |
| 845 | with the default subprocess if at all possible. |
| 846 | |
| 847 | .. deprecated:: 3.4 |
| 848 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 849 | |
Terry Jan Reedy | bb37b4c | 2014-12-04 01:26:04 -0500 | [diff] [blame] | 850 | Help and preferences |
| 851 | -------------------- |
| 852 | |
Cheryl Sabella | 01421be | 2018-12-20 00:38:54 -0500 | [diff] [blame] | 853 | .. _help-sources: |
| 854 | |
Terry Jan Reedy | 1803263 | 2018-10-28 16:21:18 -0400 | [diff] [blame] | 855 | Help sources |
| 856 | ^^^^^^^^^^^^ |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 857 | |
Terry Jan Reedy | 1803263 | 2018-10-28 16:21:18 -0400 | [diff] [blame] | 858 | Help menu entry "IDLE Help" displays a formatted html version of the |
| 859 | IDLE chapter of the Library Reference. The result, in a read-only |
| 860 | tkinter text window, is close to what one sees in a web browser. |
| 861 | Navigate through the text with a mousewheel, |
| 862 | the scrollbar, or up and down arrow keys held down. |
| 863 | Or click the TOC (Table of Contents) button and select a section |
| 864 | header in the opened box. |
| 865 | |
| 866 | Help menu entry "Python Docs" opens the extensive sources of help, |
Tal Einat | d6c08db | 2020-01-06 01:51:48 +0200 | [diff] [blame] | 867 | including tutorials, available at ``docs.python.org/x.y``, where 'x.y' |
Terry Jan Reedy | 1803263 | 2018-10-28 16:21:18 -0400 | [diff] [blame] | 868 | is the currently running Python version. If your system |
| 869 | has an off-line copy of the docs (this may be an installation option), |
| 870 | that will be opened instead. |
| 871 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 872 | Selected URLs can be added or removed from the help menu at any time using the |
Tal Einat | d6c08db | 2020-01-06 01:51:48 +0200 | [diff] [blame] | 873 | General tab of the Configure IDLE dialog. |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 874 | |
Terry Jan Reedy | 292cd6e | 2018-12-20 06:06:29 -0500 | [diff] [blame] | 875 | .. _preferences: |
| 876 | |
Terry Jan Reedy | bb37b4c | 2014-12-04 01:26:04 -0500 | [diff] [blame] | 877 | Setting preferences |
| 878 | ^^^^^^^^^^^^^^^^^^^ |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 879 | |
| 880 | The font preferences, highlighting, keys, and general preferences can be |
Terry Jan Reedy | 292cd6e | 2018-12-20 06:06:29 -0500 | [diff] [blame] | 881 | changed via Configure IDLE on the Option menu. |
Tal Einat | d6c08db | 2020-01-06 01:51:48 +0200 | [diff] [blame] | 882 | Non-default user settings are saved in a ``.idlerc`` directory in the user's |
Terry Jan Reedy | 292cd6e | 2018-12-20 06:06:29 -0500 | [diff] [blame] | 883 | home directory. Problems caused by bad user configuration files are solved |
Tal Einat | d6c08db | 2020-01-06 01:51:48 +0200 | [diff] [blame] | 884 | by editing or deleting one or more of the files in ``.idlerc``. |
Terry Jan Reedy | 292cd6e | 2018-12-20 06:06:29 -0500 | [diff] [blame] | 885 | |
Terry Jan Reedy | d610116 | 2019-02-23 23:04:53 -0500 | [diff] [blame] | 886 | On the Font tab, see the text sample for the effect of font face and size |
| 887 | on multiple characters in multiple languages. Edit the sample to add |
| 888 | other characters of personal interest. Use the sample to select |
| 889 | monospaced fonts. If particular characters have problems in Shell or an |
| 890 | editor, add them to the top of the sample and try changing first size |
| 891 | and then font. |
| 892 | |
Terry Jan Reedy | 292cd6e | 2018-12-20 06:06:29 -0500 | [diff] [blame] | 893 | On the Highlights and Keys tab, select a built-in or custom color theme |
| 894 | and key set. To use a newer built-in color theme or key set with older |
| 895 | IDLEs, save it as a new custom theme or key set and it well be accessible |
| 896 | to older IDLEs. |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 897 | |
Terry Jan Reedy | b65413b | 2018-11-15 13:15:13 -0500 | [diff] [blame] | 898 | IDLE on macOS |
Terry Jan Reedy | 50ff02b | 2018-11-10 23:26:31 -0500 | [diff] [blame] | 899 | ^^^^^^^^^^^^^ |
| 900 | |
| 901 | Under System Preferences: Dock, one can set "Prefer tabs when opening |
| 902 | documents" to "Always". This setting is not compatible with the tk/tkinter |
| 903 | GUI framework used by IDLE, and it breaks a few IDLE features. |
| 904 | |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 905 | Extensions |
Terry Jan Reedy | bb37b4c | 2014-12-04 01:26:04 -0500 | [diff] [blame] | 906 | ^^^^^^^^^^ |
Andrew Svetlov | 1bd7f02 | 2013-01-14 19:27:36 +0200 | [diff] [blame] | 907 | |
csabella | 9dc2b38 | 2017-04-29 18:28:36 -0400 | [diff] [blame] | 908 | IDLE contains an extension facility. Preferences for extensions can be |
Terry Jan Reedy | adb4cd2 | 2017-09-12 07:45:15 -0400 | [diff] [blame] | 909 | changed with the Extensions tab of the preferences dialog. See the |
| 910 | beginning of config-extensions.def in the idlelib directory for further |
| 911 | information. The only current default extension is zzdummy, an example |
| 912 | also used for testing. |