| 1 | <!DOCTYPE html> |
| 2 | |
| 3 | <html lang="en"> |
| 4 | <head> |
| 5 | <meta charset="utf-8" /> |
| 6 | <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" /> |
| 7 | |
| 8 | <title>IDLE — Python 3.13.0a2 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 9 | |
| 10 | <link rel="stylesheet" type="text/css" href="../_static/pygments.css" /> |
| 11 | <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?digest=b37c26da2f7529d09fe70b41c4b2133fe4931a90" /> |
| 12 | <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css" /> |
| 13 | |
| 14 | <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> |
| 15 | <script src="../_static/doctools.js"></script> |
| 16 | <script src="../_static/sphinx_highlight.js"></script> |
| 17 | |
| 18 | <script src="../_static/sidebar.js"></script> |
| 19 | |
| 20 | <link rel="search" type="application/opensearchdescription+xml" |
| 21 | title="Search within Python 3.13.0a2 documentation" |
| 22 | href="../_static/opensearch.xml"/> |
| 23 | <link rel="author" title="About these documents" href="../about.html" /> |
| 24 | <link rel="index" title="Index" href="../genindex.html" /> |
| 25 | <link rel="search" title="Search" href="../search.html" /> |
| 26 | <link rel="copyright" title="Copyright" href="../copyright.html" /> |
| 27 | <link rel="next" title="Development Tools" href="development.html" /> |
| 28 | <link rel="prev" title="tkinter.ttk — Tk themed widgets" href="tkinter.ttk.html" /> |
| 29 | <link rel="canonical" href="https://docs.python.org/3/library/idle.html" /> |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | <style> |
| 36 | @media only screen { |
| 37 | table.full-width-table { |
| 38 | width: 100%; |
| 39 | } |
| 40 | } |
| 41 | </style> |
| 42 | <link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css"> |
| 43 | <link rel="shortcut icon" type="image/png" href="../_static/py.svg" /> |
| 44 | <script type="text/javascript" src="../_static/copybutton.js"></script> |
| 45 | <script type="text/javascript" src="../_static/menu.js"></script> |
| 46 | <script type="text/javascript" src="../_static/search-focus.js"></script> |
| 47 | <script type="text/javascript" src="../_static/themetoggle.js"></script> |
| 48 | |
| 49 | </head> |
| 50 | <body> |
| 51 | <div class="mobile-nav"> |
| 52 | <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation" |
| 53 | aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" /> |
| 54 | <nav class="nav-content" role="navigation"> |
| 55 | <label for="menuToggler" class="toggler__label"> |
| 56 | <span></span> |
| 57 | </label> |
| 58 | <span class="nav-items-wrapper"> |
| 59 | <a href="https://www.python.org/" class="nav-logo"> |
| 60 | <img src="../_static/py.svg" alt="Logo"/> |
| 61 | </a> |
| 62 | <span class="version_switcher_placeholder"></span> |
| 63 | <form role="search" class="search" action="../search.html" method="get"> |
| 64 | <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon"> |
| 65 | <path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path> |
| 66 | </svg> |
| 67 | <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" /> |
| 68 | <input type="submit" value="Go"/> |
| 69 | </form> |
| 70 | </span> |
| 71 | </nav> |
| 72 | <div class="menu-wrapper"> |
| 73 | <nav class="menu" role="navigation" aria-label="main navigation"> |
| 74 | <div class="language_switcher_placeholder"></div> |
| 75 | |
| 76 | <label class="theme-selector-label"> |
| 77 | Theme |
| 78 | <select class="theme-selector" oninput="activateTheme(this.value)"> |
| 79 | <option value="auto" selected>Auto</option> |
| 80 | <option value="light">Light</option> |
| 81 | <option value="dark">Dark</option> |
| 82 | </select> |
| 83 | </label> |
| 84 | <div> |
| 85 | <h3><a href="../contents.html">Table of Contents</a></h3> |
| 86 | <ul> |
| 87 | <li><a class="reference internal" href="#">IDLE</a><ul> |
| 88 | <li><a class="reference internal" href="#menus">Menus</a><ul> |
| 89 | <li><a class="reference internal" href="#file-menu-shell-and-editor">File menu (Shell and Editor)</a></li> |
| 90 | <li><a class="reference internal" href="#edit-menu-shell-and-editor">Edit menu (Shell and Editor)</a></li> |
| 91 | <li><a class="reference internal" href="#format-menu-editor-window-only">Format menu (Editor window only)</a></li> |
| 92 | <li><a class="reference internal" href="#run-menu-editor-window-only">Run menu (Editor window only)</a></li> |
| 93 | <li><a class="reference internal" href="#shell-menu-shell-window-only">Shell menu (Shell window only)</a></li> |
| 94 | <li><a class="reference internal" href="#debug-menu-shell-window-only">Debug menu (Shell window only)</a></li> |
| 95 | <li><a class="reference internal" href="#options-menu-shell-and-editor">Options menu (Shell and Editor)</a></li> |
| 96 | <li><a class="reference internal" href="#window-menu-shell-and-editor">Window menu (Shell and Editor)</a></li> |
| 97 | <li><a class="reference internal" href="#help-menu-shell-and-editor">Help menu (Shell and Editor)</a></li> |
| 98 | <li><a class="reference internal" href="#context-menus">Context menus</a></li> |
| 99 | </ul> |
| 100 | </li> |
| 101 | <li><a class="reference internal" href="#editing-and-navigation">Editing and Navigation</a><ul> |
| 102 | <li><a class="reference internal" href="#editor-windows">Editor windows</a></li> |
| 103 | <li><a class="reference internal" href="#key-bindings">Key bindings</a></li> |
| 104 | <li><a class="reference internal" href="#automatic-indentation">Automatic indentation</a></li> |
| 105 | <li><a class="reference internal" href="#search-and-replace">Search and Replace</a></li> |
| 106 | <li><a class="reference internal" href="#completions">Completions</a></li> |
| 107 | <li><a class="reference internal" href="#calltips">Calltips</a></li> |
| 108 | <li><a class="reference internal" href="#code-context">Code Context</a></li> |
| 109 | <li><a class="reference internal" href="#shell-window">Shell window</a></li> |
| 110 | <li><a class="reference internal" href="#text-colors">Text colors</a></li> |
| 111 | </ul> |
| 112 | </li> |
| 113 | <li><a class="reference internal" href="#startup-and-code-execution">Startup and Code Execution</a><ul> |
| 114 | <li><a class="reference internal" href="#command-line-usage">Command line usage</a></li> |
| 115 | <li><a class="reference internal" href="#startup-failure">Startup failure</a></li> |
| 116 | <li><a class="reference internal" href="#running-user-code">Running user code</a></li> |
| 117 | <li><a class="reference internal" href="#user-output-in-shell">User output in Shell</a></li> |
| 118 | <li><a class="reference internal" href="#developing-tkinter-applications">Developing tkinter applications</a></li> |
| 119 | <li><a class="reference internal" href="#running-without-a-subprocess">Running without a subprocess</a></li> |
| 120 | </ul> |
| 121 | </li> |
| 122 | <li><a class="reference internal" href="#help-and-preferences">Help and Preferences</a><ul> |
| 123 | <li><a class="reference internal" href="#help-sources">Help sources</a></li> |
| 124 | <li><a class="reference internal" href="#setting-preferences">Setting preferences</a></li> |
| 125 | <li><a class="reference internal" href="#idle-on-macos">IDLE on macOS</a></li> |
| 126 | <li><a class="reference internal" href="#extensions">Extensions</a></li> |
| 127 | </ul> |
| 128 | </li> |
| 129 | <li><a class="reference internal" href="#module-idlelib">idlelib</a></li> |
| 130 | </ul> |
| 131 | </li> |
| 132 | </ul> |
| 133 | |
| 134 | </div> |
| 135 | <div> |
| 136 | <h4>Previous topic</h4> |
| 137 | <p class="topless"><a href="tkinter.ttk.html" |
| 138 | title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.ttk</span></code> — Tk themed widgets</a></p> |
| 139 | </div> |
| 140 | <div> |
| 141 | <h4>Next topic</h4> |
| 142 | <p class="topless"><a href="development.html" |
| 143 | title="next chapter">Development Tools</a></p> |
| 144 | </div> |
| 145 | <div role="note" aria-label="source link"> |
| 146 | <h3>This Page</h3> |
| 147 | <ul class="this-page-menu"> |
| 148 | <li><a href="../bugs.html">Report a Bug</a></li> |
| 149 | <li> |
| 150 | <a href="https://github.com/python/cpython/blob/main/Doc/library/idle.rst" |
| 151 | rel="nofollow">Show Source |
| 152 | </a> |
| 153 | </li> |
| 154 | </ul> |
| 155 | </div> |
| 156 | </nav> |
| 157 | </div> |
| 158 | </div> |
| 159 | |
| 160 | |
| 161 | <div class="related" role="navigation" aria-label="related navigation"> |
| 162 | <h3>Navigation</h3> |
| 163 | <ul> |
| 164 | <li class="right" style="margin-right: 10px"> |
| 165 | <a href="../genindex.html" title="General Index" |
| 166 | accesskey="I">index</a></li> |
| 167 | <li class="right" > |
| 168 | <a href="../py-modindex.html" title="Python Module Index" |
| 169 | >modules</a> |</li> |
| 170 | <li class="right" > |
| 171 | <a href="development.html" title="Development Tools" |
| 172 | accesskey="N">next</a> |</li> |
| 173 | <li class="right" > |
| 174 | <a href="tkinter.ttk.html" title="tkinter.ttk — Tk themed widgets" |
| 175 | accesskey="P">previous</a> |</li> |
| 176 | |
| 177 | <li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li> |
| 178 | <li><a href="https://www.python.org/">Python</a> »</li> |
| 179 | <li class="switchers"> |
| 180 | <div class="language_switcher_placeholder"></div> |
| 181 | <div class="version_switcher_placeholder"></div> |
| 182 | </li> |
| 183 | <li> |
| 184 | |
| 185 | </li> |
| 186 | <li id="cpython-language-and-version"> |
| 187 | <a href="../index.html">3.13.0a2 Documentation</a> » |
| 188 | </li> |
| 189 | |
| 190 | <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li> |
| 191 | <li class="nav-item nav-item-2"><a href="tk.html" accesskey="U">Graphical User Interfaces with Tk</a> »</li> |
| 192 | <li class="nav-item nav-item-this"><a href="">IDLE</a></li> |
| 193 | <li class="right"> |
| 194 | |
| 195 | |
| 196 | <div class="inline-search" role="search"> |
| 197 | <form class="inline-search" action="../search.html" method="get"> |
| 198 | <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" /> |
| 199 | <input type="submit" value="Go" /> |
| 200 | </form> |
| 201 | </div> |
| 202 | | |
| 203 | </li> |
| 204 | <li class="right"> |
| 205 | <label class="theme-selector-label"> |
| 206 | Theme |
| 207 | <select class="theme-selector" oninput="activateTheme(this.value)"> |
| 208 | <option value="auto" selected>Auto</option> |
| 209 | <option value="light">Light</option> |
| 210 | <option value="dark">Dark</option> |
| 211 | </select> |
| 212 | </label> |</li> |
| 213 | |
| 214 | </ul> |
| 215 | </div> |
| 216 | |
| 217 | <div class="document"> |
| 218 | <div class="documentwrapper"> |
| 219 | <div class="bodywrapper"> |
| 220 | <div class="body" role="main"> |
| 221 | |
| 222 | <section id="idle"> |
| 223 | <span id="id1"></span><h1>IDLE<a class="headerlink" href="#idle" title="Permalink to this heading">¶</a></h1> |
| 224 | <p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/main/Lib/idlelib/">Lib/idlelib/</a></p> |
| 225 | <hr class="docutils" id="index-0" /> |
| 226 | <p>IDLE is Python’s Integrated Development and Learning Environment.</p> |
| 227 | <p>IDLE has the following features:</p> |
| 228 | <ul class="simple"> |
| 229 | <li><p>cross-platform: works mostly the same on Windows, Unix, and macOS</p></li> |
| 230 | <li><p>Python shell window (interactive interpreter) with colorizing |
| 231 | of code input, output, and error messages</p></li> |
| 232 | <li><p>multi-window text editor with multiple undo, Python colorizing, |
| 233 | smart indent, call tips, auto completion, and other features</p></li> |
| 234 | <li><p>search within any window, replace within editor windows, and search |
| 235 | through multiple files (grep)</p></li> |
| 236 | <li><p>debugger with persistent breakpoints, stepping, and viewing |
| 237 | of global and local namespaces</p></li> |
| 238 | <li><p>configuration, browsers, and other dialogs</p></li> |
| 239 | </ul> |
| 240 | <section id="menus"> |
| 241 | <h2>Menus<a class="headerlink" href="#menus" title="Permalink to this heading">¶</a></h2> |
| 242 | <p>IDLE has two main window types, the Shell window and the Editor window. It is |
| 243 | possible to have multiple editor windows simultaneously. On Windows and |
| 244 | Linux, each has its own top menu. Each menu documented below indicates |
| 245 | which window type it is associated with.</p> |
| 246 | <p>Output windows, such as used for Edit => Find in Files, are a subtype of editor |
| 247 | window. They currently have the same top menu but a different |
| 248 | default title and context menu.</p> |
| 249 | <p>On macOS, there is one application menu. It dynamically changes according |
| 250 | to the window currently selected. It has an IDLE menu, and some entries |
| 251 | described below are moved around to conform to Apple guidelines.</p> |
| 252 | <section id="file-menu-shell-and-editor"> |
| 253 | <h3>File menu (Shell and Editor)<a class="headerlink" href="#file-menu-shell-and-editor" title="Permalink to this heading">¶</a></h3> |
| 254 | <dl class="simple"> |
| 255 | <dt>New File</dt><dd><p>Create a new file editing window.</p> |
| 256 | </dd> |
| 257 | <dt>Open…</dt><dd><p>Open an existing file with an Open dialog.</p> |
| 258 | </dd> |
| 259 | <dt>Open Module…</dt><dd><p>Open an existing module (searches sys.path).</p> |
| 260 | </dd> |
| 261 | <dt>Recent Files</dt><dd><p>Open a list of recent files. Click one to open it.</p> |
| 262 | </dd> |
| 263 | </dl> |
| 264 | <dl class="simple" id="index-1"> |
| 265 | <dt>Module Browser</dt><dd><p>Show functions, classes, and methods in the current Editor file in a |
| 266 | tree structure. In the shell, open a module first.</p> |
| 267 | </dd> |
| 268 | <dt>Path Browser</dt><dd><p>Show sys.path directories, modules, functions, classes and methods in a |
| 269 | tree structure.</p> |
| 270 | </dd> |
| 271 | <dt>Save</dt><dd><p>Save the current window to the associated file, if there is one. Windows |
| 272 | that have been changed since being opened or last saved have a * before |
| 273 | and after the window title. If there is no associated file, |
| 274 | do Save As instead.</p> |
| 275 | </dd> |
| 276 | <dt>Save As…</dt><dd><p>Save the current window with a Save As dialog. The file saved becomes the |
| 277 | new associated file for the window. (If your file namager is set to hide |
| 278 | extensions, the current extension will be omitted in the file name box. |
| 279 | If the new filename has no ‘.’, ‘.py’ and ‘.txt’ will be added for Python |
| 280 | and text files, except that on macOS Aqua,’.py’ is added for all files.)</p> |
| 281 | </dd> |
| 282 | <dt>Save Copy As…</dt><dd><p>Save the current window to different file without changing the associated |
| 283 | file. (See Save As note above about filename extensions.)</p> |
| 284 | </dd> |
| 285 | <dt>Print Window</dt><dd><p>Print the current window to the default printer.</p> |
| 286 | </dd> |
| 287 | <dt>Close Window</dt><dd><p>Close the current window (if an unsaved editor, ask to save; if an unsaved |
| 288 | Shell, ask to quit execution). Calling <code class="docutils literal notranslate"><span class="pre">exit()</span></code> or <code class="docutils literal notranslate"><span class="pre">close()</span></code> in the Shell |
| 289 | window also closes Shell. If this is the only window, also exit IDLE.</p> |
| 290 | </dd> |
| 291 | <dt>Exit IDLE</dt><dd><p>Close all windows and quit IDLE (ask to save unsaved edit windows).</p> |
| 292 | </dd> |
| 293 | </dl> |
| 294 | </section> |
| 295 | <section id="edit-menu-shell-and-editor"> |
| 296 | <h3>Edit menu (Shell and Editor)<a class="headerlink" href="#edit-menu-shell-and-editor" title="Permalink to this heading">¶</a></h3> |
| 297 | <dl class="simple"> |
| 298 | <dt>Undo</dt><dd><p>Undo the last change to the current window. A maximum of 1000 changes may |
| 299 | be undone.</p> |
| 300 | </dd> |
| 301 | <dt>Redo</dt><dd><p>Redo the last undone change to the current window.</p> |
| 302 | </dd> |
| 303 | <dt>Select All</dt><dd><p>Select the entire contents of the current window.</p> |
| 304 | </dd> |
| 305 | <dt>Cut</dt><dd><p>Copy selection into the system-wide clipboard; then delete the selection.</p> |
| 306 | </dd> |
| 307 | <dt>Copy</dt><dd><p>Copy selection into the system-wide clipboard.</p> |
| 308 | </dd> |
| 309 | <dt>Paste</dt><dd><p>Insert contents of the system-wide clipboard into the current window.</p> |
| 310 | </dd> |
| 311 | </dl> |
| 312 | <p>The clipboard functions are also available in context menus.</p> |
| 313 | <dl class="simple"> |
| 314 | <dt>Find…</dt><dd><p>Open a search dialog with many options</p> |
| 315 | </dd> |
| 316 | <dt>Find Again</dt><dd><p>Repeat the last search, if there is one.</p> |
| 317 | </dd> |
| 318 | <dt>Find Selection</dt><dd><p>Search for the currently selected string, if there is one.</p> |
| 319 | </dd> |
| 320 | <dt>Find in Files…</dt><dd><p>Open a file search dialog. Put results in a new output window.</p> |
| 321 | </dd> |
| 322 | <dt>Replace…</dt><dd><p>Open a search-and-replace dialog.</p> |
| 323 | </dd> |
| 324 | <dt>Go to Line</dt><dd><p>Move the cursor to the beginning of the line requested and make that |
| 325 | line visible. A request past the end of the file goes to the end. |
| 326 | Clear any selection and update the line and column status.</p> |
| 327 | </dd> |
| 328 | <dt>Show Completions</dt><dd><p>Open a scrollable list allowing selection of existing names. See |
| 329 | <a class="reference internal" href="#completions"><span class="std std-ref">Completions</span></a> in the Editing and navigation section below.</p> |
| 330 | </dd> |
| 331 | <dt>Expand Word</dt><dd><p>Expand a prefix you have typed to match a full word in the same window; |
| 332 | repeat to get a different expansion.</p> |
| 333 | </dd> |
| 334 | <dt>Show Call Tip</dt><dd><p>After an unclosed parenthesis for a function, open a small window with |
| 335 | function parameter hints. See <a class="reference internal" href="#calltips"><span class="std std-ref">Calltips</span></a> in the |
| 336 | Editing and navigation section below.</p> |
| 337 | </dd> |
| 338 | <dt>Show Surrounding Parens</dt><dd><p>Highlight the surrounding parenthesis.</p> |
| 339 | </dd> |
| 340 | </dl> |
| 341 | </section> |
| 342 | <section id="format-menu-editor-window-only"> |
| 343 | <span id="format-menu"></span><h3>Format menu (Editor window only)<a class="headerlink" href="#format-menu-editor-window-only" title="Permalink to this heading">¶</a></h3> |
| 344 | <dl class="simple"> |
| 345 | <dt>Format Paragraph</dt><dd><p>Reformat the current blank-line-delimited paragraph in comment block or |
| 346 | multiline string or selected line in a string. All lines in the |
| 347 | paragraph will be formatted to less than N columns, where N defaults to 72.</p> |
| 348 | </dd> |
| 349 | <dt>Indent Region</dt><dd><p>Shift selected lines right by the indent width (default 4 spaces).</p> |
| 350 | </dd> |
| 351 | <dt>Dedent Region</dt><dd><p>Shift selected lines left by the indent width (default 4 spaces).</p> |
| 352 | </dd> |
| 353 | <dt>Comment Out Region</dt><dd><p>Insert ## in front of selected lines.</p> |
| 354 | </dd> |
| 355 | <dt>Uncomment Region</dt><dd><p>Remove leading # or ## from selected lines.</p> |
| 356 | </dd> |
| 357 | <dt>Tabify Region</dt><dd><p>Turn <em>leading</em> stretches of spaces into tabs. (Note: We recommend using |
| 358 | 4 space blocks to indent Python code.)</p> |
| 359 | </dd> |
| 360 | <dt>Untabify Region</dt><dd><p>Turn <em>all</em> tabs into the correct number of spaces.</p> |
| 361 | </dd> |
| 362 | <dt>Toggle Tabs</dt><dd><p>Open a dialog to switch between indenting with spaces and tabs.</p> |
| 363 | </dd> |
| 364 | <dt>New Indent Width</dt><dd><p>Open a dialog to change indent width. The accepted default by the Python |
| 365 | community is 4 spaces.</p> |
| 366 | </dd> |
| 367 | <dt>Strip Trailing Chitespace</dt><dd><p>Remove trailing space and other whitespace characters after the last |
| 368 | non-whitespace character of a line by applying str.rstrip to each line, |
| 369 | including lines within multiline strings. Except for Shell windows, |
| 370 | remove extra newlines at the end of the file.</p> |
| 371 | </dd> |
| 372 | </dl> |
| 373 | </section> |
| 374 | <section id="run-menu-editor-window-only"> |
| 375 | <span id="index-2"></span><h3>Run menu (Editor window only)<a class="headerlink" href="#run-menu-editor-window-only" title="Permalink to this heading">¶</a></h3> |
| 376 | <dl class="simple" id="run-module"> |
| 377 | <dt>Run Module</dt><dd><p>Do <a class="reference internal" href="#check-module"><span class="std std-ref">Check Module</span></a>. If no error, restart the shell to clean the |
| 378 | environment, then execute the module. Output is displayed in the Shell |
| 379 | window. Note that output requires use of <code class="docutils literal notranslate"><span class="pre">print</span></code> or <code class="docutils literal notranslate"><span class="pre">write</span></code>. |
| 380 | When execution is complete, the Shell retains focus and displays a prompt. |
| 381 | At this point, one may interactively explore the result of execution. |
| 382 | This is similar to executing a file with <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-i</span> <span class="pre">file</span></code> at a command |
| 383 | line.</p> |
| 384 | </dd> |
| 385 | </dl> |
| 386 | <dl class="simple" id="run-custom"> |
| 387 | <dt>Run… Customized</dt><dd><p>Same as <a class="reference internal" href="#run-module"><span class="std std-ref">Run Module</span></a>, but run the module with customized |
| 388 | settings. <em>Command Line Arguments</em> extend <a class="reference internal" href="sys.html#sys.argv" title="sys.argv"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.argv</span></code></a> as if passed |
| 389 | on a command line. The module can be run in the Shell without restarting.</p> |
| 390 | </dd> |
| 391 | </dl> |
| 392 | <dl class="simple" id="check-module"> |
| 393 | <dt>Check Module</dt><dd><p>Check the syntax of the module currently open in the Editor window. If the |
| 394 | module has not been saved IDLE will either prompt the user to save or |
| 395 | autosave, as selected in the General tab of the Idle Settings dialog. If |
| 396 | there is a syntax error, the approximate location is indicated in the |
| 397 | Editor window.</p> |
| 398 | </dd> |
| 399 | </dl> |
| 400 | <dl class="simple" id="python-shell"> |
| 401 | <dt>Python Shell</dt><dd><p>Open or wake up the Python Shell window.</p> |
| 402 | </dd> |
| 403 | </dl> |
| 404 | </section> |
| 405 | <section id="shell-menu-shell-window-only"> |
| 406 | <h3>Shell menu (Shell window only)<a class="headerlink" href="#shell-menu-shell-window-only" title="Permalink to this heading">¶</a></h3> |
| 407 | <dl class="simple"> |
| 408 | <dt>View Last Restart</dt><dd><p>Scroll the shell window to the last Shell restart.</p> |
| 409 | </dd> |
| 410 | <dt>Restart Shell</dt><dd><p>Restart the shell to clean the environment and reset display and exception handling.</p> |
| 411 | </dd> |
| 412 | <dt>Previous History</dt><dd><p>Cycle through earlier commands in history which match the current entry.</p> |
| 413 | </dd> |
| 414 | <dt>Next History</dt><dd><p>Cycle through later commands in history which match the current entry.</p> |
| 415 | </dd> |
| 416 | <dt>Interrupt Execution</dt><dd><p>Stop a running program.</p> |
| 417 | </dd> |
| 418 | </dl> |
| 419 | </section> |
| 420 | <section id="debug-menu-shell-window-only"> |
| 421 | <h3>Debug menu (Shell window only)<a class="headerlink" href="#debug-menu-shell-window-only" title="Permalink to this heading">¶</a></h3> |
| 422 | <dl class="simple"> |
| 423 | <dt>Go to File/Line</dt><dd><p>Look on the current line. with the cursor, and the line above for a filename |
| 424 | and line number. If found, open the file if not already open, and show the |
| 425 | line. Use this to view source lines referenced in an exception traceback |
| 426 | and lines found by Find in Files. Also available in the context menu of |
| 427 | the Shell window and Output windows.</p> |
| 428 | </dd> |
| 429 | </dl> |
| 430 | <dl class="simple" id="index-3"> |
| 431 | <dt>Debugger (toggle)</dt><dd><p>When activated, code entered in the Shell or run from an Editor will run |
| 432 | under the debugger. In the Editor, breakpoints can be set with the context |
| 433 | menu. This feature is still incomplete and somewhat experimental.</p> |
| 434 | </dd> |
| 435 | <dt>Stack Viewer</dt><dd><p>Show the stack traceback of the last exception in a tree widget, with |
| 436 | access to locals and globals.</p> |
| 437 | </dd> |
| 438 | <dt>Auto-open Stack Viewer</dt><dd><p>Toggle automatically opening the stack viewer on an unhandled exception.</p> |
| 439 | </dd> |
| 440 | </dl> |
| 441 | </section> |
| 442 | <section id="options-menu-shell-and-editor"> |
| 443 | <h3>Options menu (Shell and Editor)<a class="headerlink" href="#options-menu-shell-and-editor" title="Permalink to this heading">¶</a></h3> |
| 444 | <dl class="simple"> |
| 445 | <dt>Configure IDLE</dt><dd><p>Open a configuration dialog and change preferences for the following: |
| 446 | fonts, indentation, keybindings, text color themes, startup windows and |
| 447 | size, additional help sources, and extensions. On macOS, open the |
| 448 | configuration dialog by selecting Preferences in the application |
| 449 | menu. For more details, see |
| 450 | <a class="reference internal" href="#preferences"><span class="std std-ref">Setting preferences</span></a> under Help and preferences.</p> |
| 451 | </dd> |
| 452 | </dl> |
| 453 | <p>Most configuration options apply to all windows or all future windows. |
| 454 | The option items below only apply to the active window.</p> |
| 455 | <dl class="simple"> |
| 456 | <dt>Show/Hide Code Context (Editor Window only)</dt><dd><p>Open a pane at the top of the edit window which shows the block context |
| 457 | of the code which has scrolled above the top of the window. See |
| 458 | <a class="reference internal" href="#code-context"><span class="std std-ref">Code Context</span></a> in the Editing and Navigation section |
| 459 | below.</p> |
| 460 | </dd> |
| 461 | <dt>Show/Hide Line Numbers (Editor Window only)</dt><dd><p>Open a column to the left of the edit window which shows the number |
| 462 | of each line of text. The default is off, which may be changed in the |
| 463 | preferences (see <a class="reference internal" href="#preferences"><span class="std std-ref">Setting preferences</span></a>).</p> |
| 464 | </dd> |
| 465 | <dt>Zoom/Restore Height</dt><dd><p>Toggles the window between normal size and maximum height. The initial size |
| 466 | defaults to 40 lines by 80 chars unless changed on the General tab of the |
| 467 | Configure IDLE dialog. The maximum height for a screen is determined by |
| 468 | momentarily maximizing a window the first time one is zoomed on the screen. |
| 469 | Changing screen settings may invalidate the saved height. This toggle has |
| 470 | no effect when a window is maximized.</p> |
| 471 | </dd> |
| 472 | </dl> |
| 473 | </section> |
| 474 | <section id="window-menu-shell-and-editor"> |
| 475 | <h3>Window menu (Shell and Editor)<a class="headerlink" href="#window-menu-shell-and-editor" title="Permalink to this heading">¶</a></h3> |
| 476 | <p>Lists the names of all open windows; select one to bring it to the foreground |
| 477 | (deiconifying it if necessary).</p> |
| 478 | </section> |
| 479 | <section id="help-menu-shell-and-editor"> |
| 480 | <h3>Help menu (Shell and Editor)<a class="headerlink" href="#help-menu-shell-and-editor" title="Permalink to this heading">¶</a></h3> |
| 481 | <dl class="simple"> |
| 482 | <dt>About IDLE</dt><dd><p>Display version, copyright, license, credits, and more.</p> |
| 483 | </dd> |
| 484 | <dt>IDLE Help</dt><dd><p>Display this IDLE document, detailing the menu options, basic editing and |
| 485 | navigation, and other tips.</p> |
| 486 | </dd> |
| 487 | <dt>Python Docs</dt><dd><p>Access local Python documentation, if installed, or start a web browser |
| 488 | and open docs.python.org showing the latest Python documentation.</p> |
| 489 | </dd> |
| 490 | <dt>Turtle Demo</dt><dd><p>Run the turtledemo module with example Python code and turtle drawings.</p> |
| 491 | </dd> |
| 492 | </dl> |
| 493 | <p>Additional help sources may be added here with the Configure IDLE dialog under |
| 494 | the General tab. See the <a class="reference internal" href="#help-sources"><span class="std std-ref">Help sources</span></a> subsection below |
| 495 | for more on Help menu choices.</p> |
| 496 | </section> |
| 497 | <section id="context-menus"> |
| 498 | <span id="index-4"></span><h3>Context menus<a class="headerlink" href="#context-menus" title="Permalink to this heading">¶</a></h3> |
| 499 | <p>Open a context menu by right-clicking in a window (Control-click on macOS). |
| 500 | Context menus have the standard clipboard functions also on the Edit menu.</p> |
| 501 | <dl class="simple"> |
| 502 | <dt>Cut</dt><dd><p>Copy selection into the system-wide clipboard; then delete the selection.</p> |
| 503 | </dd> |
| 504 | <dt>Copy</dt><dd><p>Copy selection into the system-wide clipboard.</p> |
| 505 | </dd> |
| 506 | <dt>Paste</dt><dd><p>Insert contents of the system-wide clipboard into the current window.</p> |
| 507 | </dd> |
| 508 | </dl> |
| 509 | <p>Editor windows also have breakpoint functions. Lines with a breakpoint set are |
| 510 | specially marked. Breakpoints only have an effect when running under the |
| 511 | debugger. Breakpoints for a file are saved in the user’s <code class="docutils literal notranslate"><span class="pre">.idlerc</span></code> |
| 512 | directory.</p> |
| 513 | <dl class="simple"> |
| 514 | <dt>Set Breakpoint</dt><dd><p>Set a breakpoint on the current line.</p> |
| 515 | </dd> |
| 516 | <dt>Clear Breakpoint</dt><dd><p>Clear the breakpoint on that line.</p> |
| 517 | </dd> |
| 518 | </dl> |
| 519 | <p>Shell and Output windows also have the following.</p> |
| 520 | <dl class="simple"> |
| 521 | <dt>Go to file/line</dt><dd><p>Same as in Debug menu.</p> |
| 522 | </dd> |
| 523 | </dl> |
| 524 | <p>The Shell window also has an output squeezing facility explained in the <em>Python |
| 525 | Shell window</em> subsection below.</p> |
| 526 | <dl class="simple"> |
| 527 | <dt>Squeeze</dt><dd><p>If the cursor is over an output line, squeeze all the output between |
| 528 | the code above and the prompt below down to a ‘Squeezed text’ label.</p> |
| 529 | </dd> |
| 530 | </dl> |
| 531 | </section> |
| 532 | </section> |
| 533 | <section id="editing-and-navigation"> |
| 534 | <span id="id2"></span><h2>Editing and Navigation<a class="headerlink" href="#editing-and-navigation" title="Permalink to this heading">¶</a></h2> |
| 535 | <section id="editor-windows"> |
| 536 | <h3>Editor windows<a class="headerlink" href="#editor-windows" title="Permalink to this heading">¶</a></h3> |
| 537 | <p>IDLE may open editor windows when it starts, depending on settings |
| 538 | and how you start IDLE. Thereafter, use the File menu. There can be only |
| 539 | one open editor window for a given file.</p> |
| 540 | <p>The title bar contains the name of the file, the full path, and the version |
| 541 | of Python and IDLE running the window. The status bar contains the line |
| 542 | number (‘Ln’) and column number (‘Col’). Line numbers start with 1; |
| 543 | column numbers with 0.</p> |
| 544 | <p>IDLE assumes that files with a known .py* extension contain Python code |
| 545 | and that other files do not. Run Python code with the Run menu.</p> |
| 546 | </section> |
| 547 | <section id="key-bindings"> |
| 548 | <h3>Key bindings<a class="headerlink" href="#key-bindings" title="Permalink to this heading">¶</a></h3> |
| 549 | <p>The IDLE insertion cursor is a thin vertical bar between character |
| 550 | positions. When characters are entered, the insertion cursor and |
| 551 | everything to its right moves right one character and |
| 552 | the new character is entered in the new space.</p> |
| 553 | <p>Several non-character keys move the cursor and possibly |
| 554 | delete characters. Deletion does not puts text on the clipboard, |
| 555 | but IDLE has an undo list. Wherever this doc discusses keys, |
| 556 | ‘C’ refers to the <kbd class="kbd docutils literal notranslate">Control</kbd> key on Windows and |
| 557 | Unix and the <kbd class="kbd docutils literal notranslate">Command</kbd> key on macOS. (And all such dicussions |
| 558 | assume that the keys have not been re-bound to something else.)</p> |
| 559 | <ul class="simple"> |
| 560 | <li><p>Arrow keys move the cursor one character or line.</p></li> |
| 561 | <li><p><kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">LeftArrow</kbd></kbd> and <kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">RightArrow</kbd></kbd> moves left or right one word.</p></li> |
| 562 | <li><p><kbd class="kbd docutils literal notranslate">Home</kbd> and <kbd class="kbd docutils literal notranslate">End</kbd> go to the beginning or end of the line.</p></li> |
| 563 | <li><p><kbd class="kbd docutils literal notranslate">Page Up</kbd> and <kbd class="kbd docutils literal notranslate">Page Down</kbd> go up or down one screen.</p></li> |
| 564 | <li><p><kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">Home</kbd></kbd> and <kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">End</kbd></kbd> go to beginning or end of the file.</p></li> |
| 565 | <li><p><kbd class="kbd docutils literal notranslate">Backspace</kbd> and <kbd class="kbd docutils literal notranslate">Del</kbd> (or <cite>C-d</cite>) delete the previous or |
| 566 | next character.</p></li> |
| 567 | <li><p><kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">Backspace</kbd></kbd> and <kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">Del</kbd></kbd> delete one word left or right.</p></li> |
| 568 | <li><p><kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">k</kbd></kbd> deletes (‘kills’) everything to the right.</p></li> |
| 569 | </ul> |
| 570 | <p>Standard keybindings (like <kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">c</kbd></kbd> to copy and <kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">v</kbd></kbd> to paste) |
| 571 | may work. Keybindings are selected in the Configure IDLE dialog.</p> |
| 572 | </section> |
| 573 | <section id="automatic-indentation"> |
| 574 | <h3>Automatic indentation<a class="headerlink" href="#automatic-indentation" title="Permalink to this heading">¶</a></h3> |
| 575 | <p>After a block-opening statement, the next line is indented by 4 spaces (in the |
| 576 | Python Shell window by one tab). After certain keywords (break, return etc.) |
| 577 | the next line is dedented. In leading indentation, <kbd class="kbd docutils literal notranslate">Backspace</kbd> deletes up |
| 578 | to 4 spaces if they are there. <kbd class="kbd docutils literal notranslate">Tab</kbd> inserts spaces (in the Python |
| 579 | Shell window one tab), number depends on Indent width. Currently, tabs |
| 580 | are restricted to four spaces due to Tcl/Tk limitations.</p> |
| 581 | <p>See also the indent/dedent region commands on the |
| 582 | <a class="reference internal" href="#format-menu"><span class="std std-ref">Format menu</span></a>.</p> |
| 583 | </section> |
| 584 | <section id="search-and-replace"> |
| 585 | <h3>Search and Replace<a class="headerlink" href="#search-and-replace" title="Permalink to this heading">¶</a></h3> |
| 586 | <p>Any selection becomes a search target. However, only selections within |
| 587 | a line work because searches are only performed within lines with the |
| 588 | terminal newline removed. If <code class="docutils literal notranslate"><span class="pre">[x]</span> <span class="pre">Regular</span> <span class="pre">expression</span></code> is checked, the |
| 589 | target is interpreted according to the Python re module.</p> |
| 590 | </section> |
| 591 | <section id="completions"> |
| 592 | <span id="id3"></span><h3>Completions<a class="headerlink" href="#completions" title="Permalink to this heading">¶</a></h3> |
| 593 | <p>Completions are supplied, when requested and available, for module |
| 594 | names, attributes of classes or functions, or filenames. Each request |
| 595 | method displays a completion box with existing names. (See tab |
| 596 | completions below for an exception.) For any box, change the name |
| 597 | being completed and the item highlighted in the box by |
| 598 | typing and deleting characters; by hitting <kbd class="kbd docutils literal notranslate">Up</kbd>, <kbd class="kbd docutils literal notranslate">Down</kbd>, |
| 599 | <kbd class="kbd docutils literal notranslate">PageUp</kbd>, <kbd class="kbd docutils literal notranslate">PageDown</kbd>, <kbd class="kbd docutils literal notranslate">Home</kbd>, and <kbd class="kbd docutils literal notranslate">End</kbd> keys; |
| 600 | and by a single click within the box. Close the box with <kbd class="kbd docutils literal notranslate">Escape</kbd>, |
| 601 | <kbd class="kbd docutils literal notranslate">Enter</kbd>, and double <kbd class="kbd docutils literal notranslate">Tab</kbd> keys or clicks outside the box. |
| 602 | A double click within the box selects and closes.</p> |
| 603 | <p>One way to open a box is to type a key character and wait for a |
| 604 | predefined interval. This defaults to 2 seconds; customize it |
| 605 | in the settings dialog. (To prevent auto popups, set the delay to a |
| 606 | large number of milliseconds, such as 100000000.) For imported module |
| 607 | names or class or function attributes, type ‘.’. |
| 608 | For filenames in the root directory, type <a class="reference internal" href="os.html#os.sep" title="os.sep"><code class="xref py py-data docutils literal notranslate"><span class="pre">os.sep</span></code></a> or |
| 609 | <a class="reference internal" href="os.html#os.altsep" title="os.altsep"><code class="xref py py-data docutils literal notranslate"><span class="pre">os.altsep</span></code></a> immediately after an opening quote. (On Windows, |
| 610 | one can specify a drive first.) Move into subdirectories by typing a |
| 611 | directory name and a separator.</p> |
| 612 | <p>Instead of waiting, or after a box is closed, open a completion box |
| 613 | immediately with Show Completions on the Edit menu. The default hot |
| 614 | key is <kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">space</kbd></kbd>. If one types a prefix for the desired name |
| 615 | before opening the box, the first match or near miss is made visible. |
| 616 | The result is the same as if one enters a prefix |
| 617 | after the box is displayed. Show Completions after a quote completes |
| 618 | filenames in the current directory instead of a root directory.</p> |
| 619 | <p>Hitting <kbd class="kbd docutils literal notranslate">Tab</kbd> after a prefix usually has the same effect as Show |
| 620 | Completions. (With no prefix, it indents.) However, if there is only |
| 621 | one match to the prefix, that match is immediately added to the editor |
| 622 | text without opening a box.</p> |
| 623 | <p>Invoking ‘Show Completions’, or hitting <kbd class="kbd docutils literal notranslate">Tab</kbd> after a prefix, |
| 624 | outside of a string and without a preceding ‘.’ opens a box with |
| 625 | keywords, builtin names, and available module-level names.</p> |
| 626 | <p>When editing code in an editor (as oppose to Shell), increase the |
| 627 | available module-level names by running your code |
| 628 | and not restarting the Shell thereafter. This is especially useful |
| 629 | after adding imports at the top of a file. This also increases |
| 630 | possible attribute completions.</p> |
| 631 | <p>Completion boxes initially exclude names beginning with ‘_’ or, for |
| 632 | modules, not included in ‘__all__’. The hidden names can be accessed |
| 633 | by typing ‘_’ after ‘.’, either before or after the box is opened.</p> |
| 634 | </section> |
| 635 | <section id="calltips"> |
| 636 | <span id="id4"></span><h3>Calltips<a class="headerlink" href="#calltips" title="Permalink to this heading">¶</a></h3> |
| 637 | <p>A calltip is shown automatically when one types <kbd class="kbd docutils literal notranslate">(</kbd> after the name |
| 638 | of an <em>accessible</em> function. A function name expression may include |
| 639 | dots and subscripts. A calltip remains until it is clicked, the cursor |
| 640 | is moved out of the argument area, or <kbd class="kbd docutils literal notranslate">)</kbd> is typed. Whenever the |
| 641 | cursor is in the argument part of a definition, select Edit and “Show |
| 642 | Call Tip” on the menu or enter its shortcut to display a calltip.</p> |
| 643 | <p>The calltip consists of the function’s signature and docstring up to |
| 644 | the latter’s first blank line or the fifth non-blank line. (Some builtin |
| 645 | functions lack an accessible signature.) A ‘/’ or ‘*’ in the signature |
| 646 | indicates that the preceding or following arguments are passed by |
| 647 | position or name (keyword) only. Details are subject to change.</p> |
| 648 | <p>In Shell, the accessible functions depends on what modules have been |
| 649 | imported into the user process, including those imported by Idle itself, |
| 650 | and which definitions have been run, all since the last restart.</p> |
| 651 | <p>For example, restart the Shell and enter <code class="docutils literal notranslate"><span class="pre">itertools.count(</span></code>. A calltip |
| 652 | appears because Idle imports itertools into the user process for its own |
| 653 | use. (This could change.) Enter <code class="docutils literal notranslate"><span class="pre">turtle.write(</span></code> and nothing appears. |
| 654 | Idle does not itself import turtle. The menu entry and shortcut also do |
| 655 | nothing. Enter <code class="docutils literal notranslate"><span class="pre">import</span> <span class="pre">turtle</span></code>. Thereafter, <code class="docutils literal notranslate"><span class="pre">turtle.write(</span></code> |
| 656 | will display a calltip.</p> |
| 657 | <p>In an editor, import statements have no effect until one runs the file. |
| 658 | One might want to run a file after writing import statements, after |
| 659 | adding function definitions, or after opening an existing file.</p> |
| 660 | </section> |
| 661 | <section id="code-context"> |
| 662 | <span id="id5"></span><h3>Code Context<a class="headerlink" href="#code-context" title="Permalink to this heading">¶</a></h3> |
| 663 | <p>Within an editor window containing Python code, code context can be toggled |
| 664 | in order to show or hide a pane at the top of the window. When shown, this |
| 665 | pane freezes the opening lines for block code, such as those beginning with |
| 666 | <code class="docutils literal notranslate"><span class="pre">class</span></code>, <code class="docutils literal notranslate"><span class="pre">def</span></code>, or <code class="docutils literal notranslate"><span class="pre">if</span></code> keywords, that would have otherwise scrolled |
| 667 | out of view. The size of the pane will be expanded and contracted as needed |
| 668 | to show the all current levels of context, up to the maximum number of |
| 669 | lines defined in the Configure IDLE dialog (which defaults to 15). If there |
| 670 | are no current context lines and the feature is toggled on, a single blank |
| 671 | line will display. Clicking on a line in the context pane will move that |
| 672 | line to the top of the editor.</p> |
| 673 | <p>The text and background colors for the context pane can be configured under |
| 674 | the Highlights tab in the Configure IDLE dialog.</p> |
| 675 | </section> |
| 676 | <section id="shell-window"> |
| 677 | <h3>Shell window<a class="headerlink" href="#shell-window" title="Permalink to this heading">¶</a></h3> |
| 678 | <p>In IDLE’s Shell, enter, edit, and recall complete statements. (Most |
| 679 | consoles and terminals only work with a single physical line at a time).</p> |
| 680 | <p>Submit a single-line statement for execution by hitting <kbd class="kbd docutils literal notranslate">Return</kbd> |
| 681 | with the cursor anywhere on the line. If a line is extended with |
| 682 | Backslash (<kbd class="kbd docutils literal notranslate">\</kbd>), the cursor must be on the last physical line. |
| 683 | Submit a multi-line compound statement by entering a blank line after |
| 684 | the statement.</p> |
| 685 | <p>When one pastes code into Shell, it is not compiled and possibly executed |
| 686 | until one hits <kbd class="kbd docutils literal notranslate">Return</kbd>, as specified above. |
| 687 | One may edit pasted code first. |
| 688 | If one pastes more than one statement into Shell, the result will be a |
| 689 | <a class="reference internal" href="exceptions.html#SyntaxError" title="SyntaxError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SyntaxError</span></code></a> when multiple statements are compiled as if they were one.</p> |
| 690 | <p>Lines containing <code class="docutils literal notranslate"><span class="pre">RESTART</span></code> mean that the user execution process has been |
| 691 | re-started. This occurs when the user execution process has crashed, |
| 692 | when one requests a restart on the Shell menu, or when one runs code |
| 693 | in an editor window.</p> |
| 694 | <p>The editing features described in previous subsections work when entering |
| 695 | code interactively. IDLE’s Shell window also responds to the following:</p> |
| 696 | <ul class="simple"> |
| 697 | <li><p><kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">c</kbd></kbd> attemps to interrupt statement execution (but may fail).</p></li> |
| 698 | <li><p><kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">d</kbd></kbd> closes Shell if typed at a <code class="docutils literal notranslate"><span class="pre">>>></span></code> prompt.</p></li> |
| 699 | <li><p><kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">Alt</kbd>-<kbd class="kbd docutils literal notranslate">p</kbd></kbd> and <kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">Alt</kbd>-<kbd class="kbd docutils literal notranslate">n</kbd></kbd> (<kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">p</kbd></kbd> and <kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">n</kbd></kbd> on macOS) |
| 700 | retrieve to the current prompt the previous or next previously |
| 701 | entered statement that matches anything already typed.</p></li> |
| 702 | <li><p><kbd class="kbd docutils literal notranslate">Return</kbd> while the cursor is on any previous statement |
| 703 | appends the latter to anything already typed at the prompt.</p></li> |
| 704 | </ul> |
| 705 | </section> |
| 706 | <section id="text-colors"> |
| 707 | <h3>Text colors<a class="headerlink" href="#text-colors" title="Permalink to this heading">¶</a></h3> |
| 708 | <p>Idle defaults to black on white text, but colors text with special meanings. |
| 709 | For the shell, these are shell output, shell error, user output, and |
| 710 | user error. For Python code, at the shell prompt or in an editor, these are |
| 711 | keywords, builtin class and function names, names following <code class="docutils literal notranslate"><span class="pre">class</span></code> and |
| 712 | <code class="docutils literal notranslate"><span class="pre">def</span></code>, strings, and comments. For any text window, these are the cursor (when |
| 713 | present), found text (when possible), and selected text.</p> |
| 714 | <p>IDLE also highlights the <a class="reference internal" href="../reference/lexical_analysis.html#soft-keywords"><span class="std std-ref">soft keywords</span></a> <a class="reference internal" href="../reference/compound_stmts.html#match"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">match</span></code></a>, |
| 715 | <a class="reference internal" href="../reference/compound_stmts.html#match"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">case</span></code></a>, and <a class="reference internal" href="../reference/compound_stmts.html#wildcard-patterns"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">_</span></code></a> in |
| 716 | pattern-matching statements. However, this highlighting is not perfect and |
| 717 | will be incorrect in some rare cases, including some <code class="docutils literal notranslate"><span class="pre">_</span></code>-s in <code class="docutils literal notranslate"><span class="pre">case</span></code> |
| 718 | patterns.</p> |
| 719 | <p>Text coloring is done in the background, so uncolorized text is occasionally |
| 720 | visible. To change the color scheme, use the Configure IDLE dialog |
| 721 | Highlighting tab. The marking of debugger breakpoint lines in the editor and |
| 722 | text in popups and dialogs is not user-configurable.</p> |
| 723 | </section> |
| 724 | </section> |
| 725 | <section id="startup-and-code-execution"> |
| 726 | <h2>Startup and Code Execution<a class="headerlink" href="#startup-and-code-execution" title="Permalink to this heading">¶</a></h2> |
| 727 | <p>Upon startup with the <code class="docutils literal notranslate"><span class="pre">-s</span></code> option, IDLE will execute the file referenced by |
| 728 | the environment variables <span class="target" id="index-5"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">IDLESTARTUP</span></code> or <span class="target" id="index-6"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONSTARTUP"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONSTARTUP</span></code></a>. |
| 729 | IDLE first checks for <code class="docutils literal notranslate"><span class="pre">IDLESTARTUP</span></code>; if <code class="docutils literal notranslate"><span class="pre">IDLESTARTUP</span></code> is present the file |
| 730 | referenced is run. If <code class="docutils literal notranslate"><span class="pre">IDLESTARTUP</span></code> is not present, IDLE checks for |
| 731 | <code class="docutils literal notranslate"><span class="pre">PYTHONSTARTUP</span></code>. Files referenced by these environment variables are |
| 732 | convenient places to store functions that are used frequently from the IDLE |
| 733 | shell, or for executing import statements to import common modules.</p> |
| 734 | <p>In addition, <code class="docutils literal notranslate"><span class="pre">Tk</span></code> also loads a startup file if it is present. Note that the |
| 735 | Tk file is loaded unconditionally. This additional file is <code class="docutils literal notranslate"><span class="pre">.Idle.py</span></code> and is |
| 736 | looked for in the user’s home directory. Statements in this file will be |
| 737 | executed in the Tk namespace, so this file is not useful for importing |
| 738 | functions to be used from IDLE’s Python shell.</p> |
| 739 | <section id="command-line-usage"> |
| 740 | <h3>Command line usage<a class="headerlink" href="#command-line-usage" title="Permalink to this heading">¶</a></h3> |
| 741 | <div class="highlight-none notranslate"><div class="highlight"><pre><span></span>idle.py [-c command] [-d] [-e] [-h] [-i] [-r file] [-s] [-t title] [-] [arg] ... |
| 742 | |
| 743 | -c command run command in the shell window |
| 744 | -d enable debugger and open shell window |
| 745 | -e open editor window |
| 746 | -h print help message with legal combinations and exit |
| 747 | -i open shell window |
| 748 | -r file run file in shell window |
| 749 | -s run $IDLESTARTUP or $PYTHONSTARTUP first, in shell window |
| 750 | -t title set title of shell window |
| 751 | - run stdin in shell (- must be last option before args) |
| 752 | </pre></div> |
| 753 | </div> |
| 754 | <p>If there are arguments:</p> |
| 755 | <ul class="simple"> |
| 756 | <li><p>If <code class="docutils literal notranslate"><span class="pre">-</span></code>, <code class="docutils literal notranslate"><span class="pre">-c</span></code>, or <code class="docutils literal notranslate"><span class="pre">r</span></code> is used, all arguments are placed in |
| 757 | <code class="docutils literal notranslate"><span class="pre">sys.argv[1:...]</span></code> and <code class="docutils literal notranslate"><span class="pre">sys.argv[0]</span></code> is set to <code class="docutils literal notranslate"><span class="pre">''</span></code>, <code class="docutils literal notranslate"><span class="pre">'-c'</span></code>, |
| 758 | or <code class="docutils literal notranslate"><span class="pre">'-r'</span></code>. No editor window is opened, even if that is the default |
| 759 | set in the Options dialog.</p></li> |
| 760 | <li><p>Otherwise, arguments are files opened for editing and |
| 761 | <code class="docutils literal notranslate"><span class="pre">sys.argv</span></code> reflects the arguments passed to IDLE itself.</p></li> |
| 762 | </ul> |
| 763 | </section> |
| 764 | <section id="startup-failure"> |
| 765 | <h3>Startup failure<a class="headerlink" href="#startup-failure" title="Permalink to this heading">¶</a></h3> |
| 766 | <p>IDLE uses a socket to communicate between the IDLE GUI process and the user |
| 767 | code execution process. A connection must be established whenever the Shell |
| 768 | starts or restarts. (The latter is indicated by a divider line that says |
| 769 | ‘RESTART’). If the user process fails to connect to the GUI process, it |
| 770 | usually displays a <code class="docutils literal notranslate"><span class="pre">Tk</span></code> error box with a ‘cannot connect’ message |
| 771 | that directs the user here. It then exits.</p> |
| 772 | <p>One specific connection failure on Unix systems results from |
| 773 | misconfigured masquerading rules somewhere in a system’s network setup. |
| 774 | When IDLE is started from a terminal, one will see a message starting |
| 775 | with <code class="docutils literal notranslate"><span class="pre">**</span> <span class="pre">Invalid</span> <span class="pre">host:</span></code>. |
| 776 | The valid value is <code class="docutils literal notranslate"><span class="pre">127.0.0.1</span> <span class="pre">(idlelib.rpc.LOCALHOST)</span></code>. |
| 777 | One can diagnose with <code class="docutils literal notranslate"><span class="pre">tcpconnect</span> <span class="pre">-irv</span> <span class="pre">127.0.0.1</span> <span class="pre">6543</span></code> in one |
| 778 | terminal window and <code class="docutils literal notranslate"><span class="pre">tcplisten</span> <span class="pre"><same</span> <span class="pre">args></span></code> in another.</p> |
| 779 | <p>A common cause of failure is a user-written file with the same name as a |
| 780 | standard library module, such as <em>random.py</em> and <em>tkinter.py</em>. When such a |
| 781 | file is located in the same directory as a file that is about to be run, |
| 782 | IDLE cannot import the stdlib file. The current fix is to rename the |
| 783 | user file.</p> |
| 784 | <p>Though less common than in the past, an antivirus or firewall program may |
| 785 | stop the connection. If the program cannot be taught to allow the |
| 786 | connection, then it must be turned off for IDLE to work. It is safe to |
| 787 | allow this internal connection because no data is visible on external |
| 788 | ports. A similar problem is a network mis-configuration that blocks |
| 789 | connections.</p> |
| 790 | <p>Python installation issues occasionally stop IDLE: multiple versions can |
| 791 | clash, or a single installation might need admin access. If one undo the |
| 792 | clash, or cannot or does not want to run as admin, it might be easiest to |
| 793 | completely remove Python and start over.</p> |
| 794 | <p>A zombie pythonw.exe process could be a problem. On Windows, use Task |
| 795 | Manager to check for one and stop it if there is. Sometimes a restart |
| 796 | initiated by a program crash or Keyboard Interrupt (control-C) may fail |
| 797 | to connect. Dismissing the error box or using Restart Shell on the Shell |
| 798 | menu may fix a temporary problem.</p> |
| 799 | <p>When IDLE first starts, it attempts to read user configuration files in |
| 800 | <code class="docutils literal notranslate"><span class="pre">~/.idlerc/</span></code> (~ is one’s home directory). If there is a problem, an error |
| 801 | message should be displayed. Leaving aside random disk glitches, this can |
| 802 | be prevented by never editing the files by hand. Instead, use the |
| 803 | configuration dialog, under Options. Once there is an error in a user |
| 804 | configuration file, the best solution may be to delete it and start over |
| 805 | with the settings dialog.</p> |
| 806 | <p>If IDLE quits with no message, and it was not started from a console, try |
| 807 | starting it from a console or terminal (<code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-m</span> <span class="pre">idlelib</span></code>) and see if |
| 808 | this results in an error message.</p> |
| 809 | <p>On Unix-based systems with tcl/tk older than <code class="docutils literal notranslate"><span class="pre">8.6.11</span></code> (see |
| 810 | <code class="docutils literal notranslate"><span class="pre">About</span> <span class="pre">IDLE</span></code>) certain characters of certain fonts can cause |
| 811 | a tk failure with a message to the terminal. This can happen either |
| 812 | if one starts IDLE to edit a file with such a character or later |
| 813 | when entering such a character. If one cannot upgrade tcl/tk, |
| 814 | then re-configure IDLE to use a font that works better.</p> |
| 815 | </section> |
| 816 | <section id="running-user-code"> |
| 817 | <h3>Running user code<a class="headerlink" href="#running-user-code" title="Permalink to this heading">¶</a></h3> |
| 818 | <p>With rare exceptions, the result of executing Python code with IDLE is |
| 819 | intended to be the same as executing the same code by the default method, |
| 820 | directly with Python in a text-mode system console or terminal window. |
| 821 | However, the different interface and operation occasionally affect |
| 822 | visible results. For instance, <code class="docutils literal notranslate"><span class="pre">sys.modules</span></code> starts with more entries, |
| 823 | and <code class="docutils literal notranslate"><span class="pre">threading.active_count()</span></code> returns 2 instead of 1.</p> |
| 824 | <p>By default, IDLE runs user code in a separate OS process rather than in |
| 825 | the user interface process that runs the shell and editor. In the execution |
| 826 | process, it replaces <code class="docutils literal notranslate"><span class="pre">sys.stdin</span></code>, <code class="docutils literal notranslate"><span class="pre">sys.stdout</span></code>, and <code class="docutils literal notranslate"><span class="pre">sys.stderr</span></code> |
| 827 | with objects that get input from and send output to the Shell window. |
| 828 | The original values stored in <code class="docutils literal notranslate"><span class="pre">sys.__stdin__</span></code>, <code class="docutils literal notranslate"><span class="pre">sys.__stdout__</span></code>, and |
| 829 | <code class="docutils literal notranslate"><span class="pre">sys.__stderr__</span></code> are not touched, but may be <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p> |
| 830 | <p>Sending print output from one process to a text widget in another is |
| 831 | slower than printing to a system terminal in the same process. |
| 832 | This has the most effect when printing multiple arguments, as the string |
| 833 | for each argument, each separator, the newline are sent separately. |
| 834 | For development, this is usually not a problem, but if one wants to |
| 835 | print faster in IDLE, format and join together everything one wants |
| 836 | displayed together and then print a single string. Both format strings |
| 837 | and <a class="reference internal" href="stdtypes.html#str.join" title="str.join"><code class="xref py py-meth docutils literal notranslate"><span class="pre">str.join()</span></code></a> can help combine fields and lines.</p> |
| 838 | <p>IDLE’s standard stream replacements are not inherited by subprocesses |
| 839 | created in the execution process, whether directly by user code or by |
| 840 | modules such as multiprocessing. If such subprocess use <code class="docutils literal notranslate"><span class="pre">input</span></code> from |
| 841 | sys.stdin or <code class="docutils literal notranslate"><span class="pre">print</span></code> or <code class="docutils literal notranslate"><span class="pre">write</span></code> to sys.stdout or sys.stderr, |
| 842 | IDLE should be started in a command line window. (On Windows, |
| 843 | use <code class="docutils literal notranslate"><span class="pre">python</span></code> or <code class="docutils literal notranslate"><span class="pre">py</span></code> rather than <code class="docutils literal notranslate"><span class="pre">pythonw</span></code> or <code class="docutils literal notranslate"><span class="pre">pyw</span></code>.) |
| 844 | The secondary subprocess |
| 845 | will then be attached to that window for input and output.</p> |
| 846 | <p>If <code class="docutils literal notranslate"><span class="pre">sys</span></code> is reset by user code, such as with <code class="docutils literal notranslate"><span class="pre">importlib.reload(sys)</span></code>, |
| 847 | IDLE’s changes are lost and input from the keyboard and output to the screen |
| 848 | will not work correctly.</p> |
| 849 | <p>When Shell has the focus, it controls the keyboard and screen. This is |
| 850 | normally transparent, but functions that directly access the keyboard |
| 851 | and screen will not work. These include system-specific functions that |
| 852 | determine whether a key has been pressed and if so, which.</p> |
| 853 | <p>The IDLE code running in the execution process adds frames to the call stack |
| 854 | that would not be there otherwise. IDLE wraps <code class="docutils literal notranslate"><span class="pre">sys.getrecursionlimit</span></code> and |
| 855 | <code class="docutils literal notranslate"><span class="pre">sys.setrecursionlimit</span></code> to reduce the effect of the additional stack |
| 856 | frames.</p> |
| 857 | <p>When user code raises SystemExit either directly or by calling sys.exit, |
| 858 | IDLE returns to a Shell prompt instead of exiting.</p> |
| 859 | </section> |
| 860 | <section id="user-output-in-shell"> |
| 861 | <h3>User output in Shell<a class="headerlink" href="#user-output-in-shell" title="Permalink to this heading">¶</a></h3> |
| 862 | <p>When a program outputs text, the result is determined by the |
| 863 | corresponding output device. When IDLE executes user code, <code class="docutils literal notranslate"><span class="pre">sys.stdout</span></code> |
| 864 | and <code class="docutils literal notranslate"><span class="pre">sys.stderr</span></code> are connected to the display area of IDLE’s Shell. Some of |
| 865 | its features are inherited from the underlying Tk Text widget. Others |
| 866 | are programmed additions. Where it matters, Shell is designed for development |
| 867 | rather than production runs.</p> |
| 868 | <p>For instance, Shell never throws away output. A program that sends unlimited |
| 869 | output to Shell will eventually fill memory, resulting in a memory error. |
| 870 | In contrast, some system text windows only keep the last n lines of output. |
| 871 | A Windows console, for instance, keeps a user-settable 1 to 9999 lines, |
| 872 | with 300 the default.</p> |
| 873 | <p>A Tk Text widget, and hence IDLE’s Shell, displays characters (codepoints) in |
| 874 | the BMP (Basic Multilingual Plane) subset of Unicode. Which characters are |
| 875 | displayed with a proper glyph and which with a replacement box depends on the |
| 876 | operating system and installed fonts. Tab characters cause the following text |
| 877 | to begin after the next tab stop. (They occur every 8 ‘characters’). Newline |
| 878 | characters cause following text to appear on a new line. Other control |
| 879 | characters are ignored or displayed as a space, box, or something else, |
| 880 | depending on the operating system and font. (Moving the text cursor through |
| 881 | such output with arrow keys may exhibit some surprising spacing behavior.)</p> |
| 882 | <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">s</span> <span class="o">=</span> <span class="s1">'a</span><span class="se">\t</span><span class="s1">b</span><span class="se">\a</span><span class="s1"><</span><span class="se">\x02</span><span class="s1">><</span><span class="se">\r</span><span class="s1">></span><span class="se">\b</span><span class="s1">c</span><span class="se">\n</span><span class="s1">d'</span> <span class="c1"># Enter 22 chars.</span> |
| 883 | <span class="gp">>>> </span><span class="nb">len</span><span class="p">(</span><span class="n">s</span><span class="p">)</span> |
| 884 | <span class="go">14</span> |
| 885 | <span class="gp">>>> </span><span class="n">s</span> <span class="c1"># Display repr(s)</span> |
| 886 | <span class="go">'a\tb\x07<\x02><\r>\x08c\nd'</span> |
| 887 | <span class="gp">>>> </span><span class="nb">print</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">end</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span> <span class="c1"># Display s as is.</span> |
| 888 | <span class="go"># Result varies by OS and font. Try it.</span> |
| 889 | </pre></div> |
| 890 | </div> |
| 891 | <p>The <code class="docutils literal notranslate"><span class="pre">repr</span></code> function is used for interactive echo of expression |
| 892 | values. It returns an altered version of the input string in which |
| 893 | control codes, some BMP codepoints, and all non-BMP codepoints are |
| 894 | replaced with escape codes. As demonstrated above, it allows one to |
| 895 | identify the characters in a string, regardless of how they are displayed.</p> |
| 896 | <p>Normal and error output are generally kept separate (on separate lines) |
| 897 | from code input and each other. They each get different highlight colors.</p> |
| 898 | <p>For SyntaxError tracebacks, the normal ‘^’ marking where the error was |
| 899 | detected is replaced by coloring the text with an error highlight. |
| 900 | When code run from a file causes other exceptions, one may right click |
| 901 | on a traceback line to jump to the corresponding line in an IDLE editor. |
| 902 | The file will be opened if necessary.</p> |
| 903 | <p>Shell has a special facility for squeezing output lines down to a |
| 904 | ‘Squeezed text’ label. This is done automatically |
| 905 | for output over N lines (N = 50 by default). |
| 906 | N can be changed in the PyShell section of the General |
| 907 | page of the Settings dialog. Output with fewer lines can be squeezed by |
| 908 | right clicking on the output. This can be useful lines long enough to slow |
| 909 | down scrolling.</p> |
| 910 | <p>Squeezed output is expanded in place by double-clicking the label. |
| 911 | It can also be sent to the clipboard or a separate view window by |
| 912 | right-clicking the label.</p> |
| 913 | </section> |
| 914 | <section id="developing-tkinter-applications"> |
| 915 | <h3>Developing tkinter applications<a class="headerlink" href="#developing-tkinter-applications" title="Permalink to this heading">¶</a></h3> |
| 916 | <p>IDLE is intentionally different from standard Python in order to |
| 917 | facilitate development of tkinter programs. Enter <code class="docutils literal notranslate"><span class="pre">import</span> <span class="pre">tkinter</span> <span class="pre">as</span> <span class="pre">tk;</span> |
| 918 | <span class="pre">root</span> <span class="pre">=</span> <span class="pre">tk.Tk()</span></code> in standard Python and nothing appears. Enter the same |
| 919 | in IDLE and a tk window appears. In standard Python, one must also enter |
| 920 | <code class="docutils literal notranslate"><span class="pre">root.update()</span></code> to see the window. IDLE does the equivalent in the |
| 921 | background, about 20 times a second, which is about every 50 milliseconds. |
| 922 | Next enter <code class="docutils literal notranslate"><span class="pre">b</span> <span class="pre">=</span> <span class="pre">tk.Button(root,</span> <span class="pre">text='button');</span> <span class="pre">b.pack()</span></code>. Again, |
| 923 | nothing visibly changes in standard Python until one enters <code class="docutils literal notranslate"><span class="pre">root.update()</span></code>.</p> |
| 924 | <p>Most tkinter programs run <code class="docutils literal notranslate"><span class="pre">root.mainloop()</span></code>, which usually does not |
| 925 | return until the tk app is destroyed. If the program is run with |
| 926 | <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-i</span></code> or from an IDLE editor, a <code class="docutils literal notranslate"><span class="pre">>>></span></code> shell prompt does not |
| 927 | appear until <code class="docutils literal notranslate"><span class="pre">mainloop()</span></code> returns, at which time there is nothing left |
| 928 | to interact with.</p> |
| 929 | <p>When running a tkinter program from an IDLE editor, one can comment out |
| 930 | the mainloop call. One then gets a shell prompt immediately and can |
| 931 | interact with the live application. One just has to remember to |
| 932 | re-enable the mainloop call when running in standard Python.</p> |
| 933 | </section> |
| 934 | <section id="running-without-a-subprocess"> |
| 935 | <h3>Running without a subprocess<a class="headerlink" href="#running-without-a-subprocess" title="Permalink to this heading">¶</a></h3> |
| 936 | <p>By default, IDLE executes user code in a separate subprocess via a socket, |
| 937 | which uses the internal loopback interface. This connection is not |
| 938 | externally visible and no data is sent to or received from the internet. |
| 939 | If firewall software complains anyway, you can ignore it.</p> |
| 940 | <p>If the attempt to make the socket connection fails, Idle will notify you. |
| 941 | Such failures are sometimes transient, but if persistent, the problem |
| 942 | may be either a firewall blocking the connection or misconfiguration of |
| 943 | a particular system. Until the problem is fixed, one can run Idle with |
| 944 | the -n command line switch.</p> |
| 945 | <p>If IDLE is started with the -n command line switch it will run in a |
| 946 | single process and will not create the subprocess which runs the RPC |
| 947 | Python execution server. This can be useful if Python cannot create |
| 948 | the subprocess or the RPC socket interface on your platform. However, |
| 949 | in this mode user code is not isolated from IDLE itself. Also, the |
| 950 | environment is not restarted when Run/Run Module (F5) is selected. If |
| 951 | your code has been modified, you must reload() the affected modules and |
| 952 | re-import any specific items (e.g. from foo import baz) if the changes |
| 953 | are to take effect. For these reasons, it is preferable to run IDLE |
| 954 | with the default subprocess if at all possible.</p> |
| 955 | <div class="deprecated"> |
| 956 | <p><span class="versionmodified deprecated">Deprecated since version 3.4.</span></p> |
| 957 | </div> |
| 958 | </section> |
| 959 | </section> |
| 960 | <section id="help-and-preferences"> |
| 961 | <h2>Help and Preferences<a class="headerlink" href="#help-and-preferences" title="Permalink to this heading">¶</a></h2> |
| 962 | <section id="help-sources"> |
| 963 | <span id="id6"></span><h3>Help sources<a class="headerlink" href="#help-sources" title="Permalink to this heading">¶</a></h3> |
| 964 | <p>Help menu entry “IDLE Help” displays a formatted html version of the |
| 965 | IDLE chapter of the Library Reference. The result, in a read-only |
| 966 | tkinter text window, is close to what one sees in a web browser. |
| 967 | Navigate through the text with a mousewheel, |
| 968 | the scrollbar, or up and down arrow keys held down. |
| 969 | Or click the TOC (Table of Contents) button and select a section |
| 970 | header in the opened box.</p> |
| 971 | <p>Help menu entry “Python Docs” opens the extensive sources of help, |
| 972 | including tutorials, available at <code class="docutils literal notranslate"><span class="pre">docs.python.org/x.y</span></code>, where ‘x.y’ |
| 973 | is the currently running Python version. If your system |
| 974 | has an off-line copy of the docs (this may be an installation option), |
| 975 | that will be opened instead.</p> |
| 976 | <p>Selected URLs can be added or removed from the help menu at any time using the |
| 977 | General tab of the Configure IDLE dialog.</p> |
| 978 | </section> |
| 979 | <section id="setting-preferences"> |
| 980 | <span id="preferences"></span><h3>Setting preferences<a class="headerlink" href="#setting-preferences" title="Permalink to this heading">¶</a></h3> |
| 981 | <p>The font preferences, highlighting, keys, and general preferences can be |
| 982 | changed via Configure IDLE on the Option menu. |
| 983 | Non-default user settings are saved in a <code class="docutils literal notranslate"><span class="pre">.idlerc</span></code> directory in the user’s |
| 984 | home directory. Problems caused by bad user configuration files are solved |
| 985 | by editing or deleting one or more of the files in <code class="docutils literal notranslate"><span class="pre">.idlerc</span></code>.</p> |
| 986 | <p>On the Font tab, see the text sample for the effect of font face and size |
| 987 | on multiple characters in multiple languages. Edit the sample to add |
| 988 | other characters of personal interest. Use the sample to select |
| 989 | monospaced fonts. If particular characters have problems in Shell or an |
| 990 | editor, add them to the top of the sample and try changing first size |
| 991 | and then font.</p> |
| 992 | <p>On the Highlights and Keys tab, select a built-in or custom color theme |
| 993 | and key set. To use a newer built-in color theme or key set with older |
| 994 | IDLEs, save it as a new custom theme or key set and it well be accessible |
| 995 | to older IDLEs.</p> |
| 996 | </section> |
| 997 | <section id="idle-on-macos"> |
| 998 | <h3>IDLE on macOS<a class="headerlink" href="#idle-on-macos" title="Permalink to this heading">¶</a></h3> |
| 999 | <p>Under System Preferences: Dock, one can set “Prefer tabs when opening |
| 1000 | documents” to “Always”. This setting is not compatible with the tk/tkinter |
| 1001 | GUI framework used by IDLE, and it breaks a few IDLE features.</p> |
| 1002 | </section> |
| 1003 | <section id="extensions"> |
| 1004 | <h3>Extensions<a class="headerlink" href="#extensions" title="Permalink to this heading">¶</a></h3> |
| 1005 | <p>IDLE contains an extension facility. Preferences for extensions can be |
| 1006 | changed with the Extensions tab of the preferences dialog. See the |
| 1007 | beginning of config-extensions.def in the idlelib directory for further |
| 1008 | information. The only current default extension is zzdummy, an example |
| 1009 | also used for testing.</p> |
| 1010 | </section> |
| 1011 | </section> |
| 1012 | <section id="module-idlelib"> |
| 1013 | <span id="idlelib"></span><h2>idlelib<a class="headerlink" href="#module-idlelib" title="Permalink to this heading">¶</a></h2> |
| 1014 | <p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/main/Lib/idlelib">Lib/idlelib</a></p> |
| 1015 | <hr class="docutils" /> |
| 1016 | <p>The Lib/idlelib package implements the IDLE application. See the rest |
| 1017 | of this page for how to use IDLE.</p> |
| 1018 | <p>The files in idlelib are described in idlelib/README.txt. Access it |
| 1019 | either in idlelib or click Help => About IDLE on the IDLE menu. This |
| 1020 | file also maps IDLE menu items to the code that implements the item. |
| 1021 | Except for files listed under ‘Startup’, the idlelib code is ‘private’ in |
| 1022 | sense that feature changes can be backported (see <span class="target" id="index-7"></span><a class="pep reference external" href="https://peps.python.org/pep-0434/"><strong>PEP 434</strong></a>).</p> |
| 1023 | </section> |
| 1024 | </section> |
| 1025 | |
| 1026 | |
| 1027 | <div class="clearer"></div> |
| 1028 | </div> |
| 1029 | </div> |
| 1030 | </div> |
| 1031 | <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> |
| 1032 | <div class="sphinxsidebarwrapper"> |
| 1033 | <div> |
| 1034 | <h3><a href="../contents.html">Table of Contents</a></h3> |
| 1035 | <ul> |
| 1036 | <li><a class="reference internal" href="#">IDLE</a><ul> |
| 1037 | <li><a class="reference internal" href="#menus">Menus</a><ul> |
| 1038 | <li><a class="reference internal" href="#file-menu-shell-and-editor">File menu (Shell and Editor)</a></li> |
| 1039 | <li><a class="reference internal" href="#edit-menu-shell-and-editor">Edit menu (Shell and Editor)</a></li> |
| 1040 | <li><a class="reference internal" href="#format-menu-editor-window-only">Format menu (Editor window only)</a></li> |
| 1041 | <li><a class="reference internal" href="#run-menu-editor-window-only">Run menu (Editor window only)</a></li> |
| 1042 | <li><a class="reference internal" href="#shell-menu-shell-window-only">Shell menu (Shell window only)</a></li> |
| 1043 | <li><a class="reference internal" href="#debug-menu-shell-window-only">Debug menu (Shell window only)</a></li> |
| 1044 | <li><a class="reference internal" href="#options-menu-shell-and-editor">Options menu (Shell and Editor)</a></li> |
| 1045 | <li><a class="reference internal" href="#window-menu-shell-and-editor">Window menu (Shell and Editor)</a></li> |
| 1046 | <li><a class="reference internal" href="#help-menu-shell-and-editor">Help menu (Shell and Editor)</a></li> |
| 1047 | <li><a class="reference internal" href="#context-menus">Context menus</a></li> |
| 1048 | </ul> |
| 1049 | </li> |
| 1050 | <li><a class="reference internal" href="#editing-and-navigation">Editing and Navigation</a><ul> |
| 1051 | <li><a class="reference internal" href="#editor-windows">Editor windows</a></li> |
| 1052 | <li><a class="reference internal" href="#key-bindings">Key bindings</a></li> |
| 1053 | <li><a class="reference internal" href="#automatic-indentation">Automatic indentation</a></li> |
| 1054 | <li><a class="reference internal" href="#search-and-replace">Search and Replace</a></li> |
| 1055 | <li><a class="reference internal" href="#completions">Completions</a></li> |
| 1056 | <li><a class="reference internal" href="#calltips">Calltips</a></li> |
| 1057 | <li><a class="reference internal" href="#code-context">Code Context</a></li> |
| 1058 | <li><a class="reference internal" href="#shell-window">Shell window</a></li> |
| 1059 | <li><a class="reference internal" href="#text-colors">Text colors</a></li> |
| 1060 | </ul> |
| 1061 | </li> |
| 1062 | <li><a class="reference internal" href="#startup-and-code-execution">Startup and Code Execution</a><ul> |
| 1063 | <li><a class="reference internal" href="#command-line-usage">Command line usage</a></li> |
| 1064 | <li><a class="reference internal" href="#startup-failure">Startup failure</a></li> |
| 1065 | <li><a class="reference internal" href="#running-user-code">Running user code</a></li> |
| 1066 | <li><a class="reference internal" href="#user-output-in-shell">User output in Shell</a></li> |
| 1067 | <li><a class="reference internal" href="#developing-tkinter-applications">Developing tkinter applications</a></li> |
| 1068 | <li><a class="reference internal" href="#running-without-a-subprocess">Running without a subprocess</a></li> |
| 1069 | </ul> |
| 1070 | </li> |
| 1071 | <li><a class="reference internal" href="#help-and-preferences">Help and Preferences</a><ul> |
| 1072 | <li><a class="reference internal" href="#help-sources">Help sources</a></li> |
| 1073 | <li><a class="reference internal" href="#setting-preferences">Setting preferences</a></li> |
| 1074 | <li><a class="reference internal" href="#idle-on-macos">IDLE on macOS</a></li> |
| 1075 | <li><a class="reference internal" href="#extensions">Extensions</a></li> |
| 1076 | </ul> |
| 1077 | </li> |
| 1078 | <li><a class="reference internal" href="#module-idlelib">idlelib</a></li> |
| 1079 | </ul> |
| 1080 | </li> |
| 1081 | </ul> |
| 1082 | |
| 1083 | </div> |
| 1084 | <div> |
| 1085 | <h4>Previous topic</h4> |
| 1086 | <p class="topless"><a href="tkinter.ttk.html" |
| 1087 | title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.ttk</span></code> — Tk themed widgets</a></p> |
| 1088 | </div> |
| 1089 | <div> |
| 1090 | <h4>Next topic</h4> |
| 1091 | <p class="topless"><a href="development.html" |
| 1092 | title="next chapter">Development Tools</a></p> |
| 1093 | </div> |
| 1094 | <div role="note" aria-label="source link"> |
| 1095 | <h3>This Page</h3> |
| 1096 | <ul class="this-page-menu"> |
| 1097 | <li><a href="../bugs.html">Report a Bug</a></li> |
| 1098 | <li> |
| 1099 | <a href="https://github.com/python/cpython/blob/main/Doc/library/idle.rst" |
| 1100 | rel="nofollow">Show Source |
| 1101 | </a> |
| 1102 | </li> |
| 1103 | </ul> |
| 1104 | </div> |
| 1105 | </div> |
| 1106 | <div id="sidebarbutton" title="Collapse sidebar"> |
| 1107 | <span>«</span> |
| 1108 | </div> |
| 1109 | |
| 1110 | </div> |
| 1111 | <div class="clearer"></div> |
| 1112 | </div> |
| 1113 | <div class="related" role="navigation" aria-label="related navigation"> |
| 1114 | <h3>Navigation</h3> |
| 1115 | <ul> |
| 1116 | <li class="right" style="margin-right: 10px"> |
| 1117 | <a href="../genindex.html" title="General Index" |
| 1118 | >index</a></li> |
| 1119 | <li class="right" > |
| 1120 | <a href="../py-modindex.html" title="Python Module Index" |
| 1121 | >modules</a> |</li> |
| 1122 | <li class="right" > |
| 1123 | <a href="development.html" title="Development Tools" |
| 1124 | >next</a> |</li> |
| 1125 | <li class="right" > |
| 1126 | <a href="tkinter.ttk.html" title="tkinter.ttk — Tk themed widgets" |
| 1127 | >previous</a> |</li> |
| 1128 | |
| 1129 | <li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li> |
| 1130 | <li><a href="https://www.python.org/">Python</a> »</li> |
| 1131 | <li class="switchers"> |
| 1132 | <div class="language_switcher_placeholder"></div> |
| 1133 | <div class="version_switcher_placeholder"></div> |
| 1134 | </li> |
| 1135 | <li> |
| 1136 | |
| 1137 | </li> |
| 1138 | <li id="cpython-language-and-version"> |
| 1139 | <a href="../index.html">3.13.0a2 Documentation</a> » |
| 1140 | </li> |
| 1141 | |
| 1142 | <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li> |
| 1143 | <li class="nav-item nav-item-2"><a href="tk.html" >Graphical User Interfaces with Tk</a> »</li> |
| 1144 | <li class="nav-item nav-item-this"><a href="">IDLE</a></li> |
| 1145 | <li class="right"> |
| 1146 | |
| 1147 | |
| 1148 | <div class="inline-search" role="search"> |
| 1149 | <form class="inline-search" action="../search.html" method="get"> |
| 1150 | <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" /> |
| 1151 | <input type="submit" value="Go" /> |
| 1152 | </form> |
| 1153 | </div> |
| 1154 | | |
| 1155 | </li> |
| 1156 | <li class="right"> |
| 1157 | <label class="theme-selector-label"> |
| 1158 | Theme |
| 1159 | <select class="theme-selector" oninput="activateTheme(this.value)"> |
| 1160 | <option value="auto" selected>Auto</option> |
| 1161 | <option value="light">Light</option> |
| 1162 | <option value="dark">Dark</option> |
| 1163 | </select> |
| 1164 | </label> |</li> |
| 1165 | |
| 1166 | </ul> |
| 1167 | </div> |
| 1168 | <div class="footer"> |
| 1169 | © <a href="../copyright.html">Copyright</a> 2001-2024, Python Software Foundation. |
| 1170 | <br /> |
| 1171 | This page is licensed under the Python Software Foundation License Version 2. |
| 1172 | <br /> |
| 1173 | Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License. |
| 1174 | <br /> |
| 1175 | See <a href="/license.html">History and License</a> for more information.<br /> |
| 1176 | <br /> |
| 1177 | |
| 1178 | The Python Software Foundation is a non-profit corporation. |
| 1179 | <a href="https://www.python.org/psf/donations/">Please donate.</a> |
| 1180 | <br /> |
| 1181 | <br /> |
| 1182 | |
| 1183 | Last updated on Jan 17, 2024 (06:57 UTC). |
| 1184 | <a href="/bugs.html">Found a bug</a>? |
| 1185 | <br /> |
| 1186 | |
| 1187 | Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.0.1. |
| 1188 | </div> |
| 1189 | |
| 1190 | </body> |
| 1191 | </html> |