17db96d56Sopenharmony_ci
27db96d56Sopenharmony_ci<!DOCTYPE html>
37db96d56Sopenharmony_ci
47db96d56Sopenharmony_ci<html lang="en">
57db96d56Sopenharmony_ci  <head>
67db96d56Sopenharmony_ci    <meta charset="utf-8" />
77db96d56Sopenharmony_ci    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />
87db96d56Sopenharmony_ci
97db96d56Sopenharmony_ci    <title>IDLE &#8212; Python 3.12.0a0 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
107db96d56Sopenharmony_ci
117db96d56Sopenharmony_ci    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
127db96d56Sopenharmony_ci    <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?2022.1" />
137db96d56Sopenharmony_ci
147db96d56Sopenharmony_ci    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
157db96d56Sopenharmony_ci    <script src="../_static/jquery.js"></script>
167db96d56Sopenharmony_ci    <script src="../_static/underscore.js"></script>
177db96d56Sopenharmony_ci    <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script>
187db96d56Sopenharmony_ci    <script src="../_static/doctools.js"></script>
197db96d56Sopenharmony_ci
207db96d56Sopenharmony_ci    <script src="../_static/sidebar.js"></script>
217db96d56Sopenharmony_ci
227db96d56Sopenharmony_ci    <link rel="search" type="application/opensearchdescription+xml"
237db96d56Sopenharmony_ci          title="Search within Python 3.12.0a0 documentation"
247db96d56Sopenharmony_ci          href="../_static/opensearch.xml"/>
257db96d56Sopenharmony_ci    <link rel="author" title="About these documents" href="../about.html" />
267db96d56Sopenharmony_ci    <link rel="index" title="Index" href="../genindex.html" />
277db96d56Sopenharmony_ci    <link rel="search" title="Search" href="../search.html" />
287db96d56Sopenharmony_ci    <link rel="copyright" title="Copyright" href="../copyright.html" />
297db96d56Sopenharmony_ci    <link rel="next" title="Development Tools" href="development.html" />
307db96d56Sopenharmony_ci    <link rel="prev" title="tkinter.tix — Extension widgets for Tk" href="tkinter.tix.html" />
317db96d56Sopenharmony_ci    <link rel="canonical" href="https://docs.python.org/3/library/idle.html" />
327db96d56Sopenharmony_ci
337db96d56Sopenharmony_ci
347db96d56Sopenharmony_ci
357db96d56Sopenharmony_ci
367db96d56Sopenharmony_ci
377db96d56Sopenharmony_ci    <style>
387db96d56Sopenharmony_ci      @media only screen {
397db96d56Sopenharmony_ci        table.full-width-table {
407db96d56Sopenharmony_ci            width: 100%;
417db96d56Sopenharmony_ci        }
427db96d56Sopenharmony_ci      }
437db96d56Sopenharmony_ci    </style>
447db96d56Sopenharmony_ci<link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
457db96d56Sopenharmony_ci            <script type="text/javascript" src="../_static/copybutton.js"></script>
467db96d56Sopenharmony_ci            <script type="text/javascript" src="../_static/menu.js"></script>
477db96d56Sopenharmony_ci
487db96d56Sopenharmony_ci  </head>
497db96d56Sopenharmony_ci<body>
507db96d56Sopenharmony_ci<div class="mobile-nav">
517db96d56Sopenharmony_ci    <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
527db96d56Sopenharmony_ci           aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
537db96d56Sopenharmony_ci    <label for="menuToggler" class="toggler__label">
547db96d56Sopenharmony_ci        <span></span>
557db96d56Sopenharmony_ci    </label>
567db96d56Sopenharmony_ci    <nav class="nav-content" role="navigation">
577db96d56Sopenharmony_ci         <a href="https://www.python.org/" class="nav-logo">
587db96d56Sopenharmony_ci             <img src="../_static/py.svg" alt="Logo"/>
597db96d56Sopenharmony_ci         </a>
607db96d56Sopenharmony_ci        <div class="version_switcher_placeholder"></div>
617db96d56Sopenharmony_ci        <form role="search" class="search" action="../search.html" method="get">
627db96d56Sopenharmony_ci            <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
637db96d56Sopenharmony_ci                <path fill-rule="nonzero"
647db96d56Sopenharmony_ci                        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" fill="#444"></path>
657db96d56Sopenharmony_ci            </svg>
667db96d56Sopenharmony_ci            <input type="text" name="q" aria-label="Quick search"/>
677db96d56Sopenharmony_ci            <input type="submit" value="Go"/>
687db96d56Sopenharmony_ci        </form>
697db96d56Sopenharmony_ci    </nav>
707db96d56Sopenharmony_ci    <div class="menu-wrapper">
717db96d56Sopenharmony_ci        <nav class="menu" role="navigation" aria-label="main navigation">
727db96d56Sopenharmony_ci            <div class="language_switcher_placeholder"></div>
737db96d56Sopenharmony_ci  <div>
747db96d56Sopenharmony_ci    <h3><a href="../contents.html">Table of Contents</a></h3>
757db96d56Sopenharmony_ci    <ul>
767db96d56Sopenharmony_ci<li><a class="reference internal" href="#">IDLE</a><ul>
777db96d56Sopenharmony_ci<li><a class="reference internal" href="#menus">Menus</a><ul>
787db96d56Sopenharmony_ci<li><a class="reference internal" href="#file-menu-shell-and-editor">File menu (Shell and Editor)</a></li>
797db96d56Sopenharmony_ci<li><a class="reference internal" href="#edit-menu-shell-and-editor">Edit menu (Shell and Editor)</a></li>
807db96d56Sopenharmony_ci<li><a class="reference internal" href="#format-menu-editor-window-only">Format menu (Editor window only)</a></li>
817db96d56Sopenharmony_ci<li><a class="reference internal" href="#run-menu-editor-window-only">Run menu (Editor window only)</a></li>
827db96d56Sopenharmony_ci<li><a class="reference internal" href="#shell-menu-shell-window-only">Shell menu (Shell window only)</a></li>
837db96d56Sopenharmony_ci<li><a class="reference internal" href="#debug-menu-shell-window-only">Debug menu (Shell window only)</a></li>
847db96d56Sopenharmony_ci<li><a class="reference internal" href="#options-menu-shell-and-editor">Options menu (Shell and Editor)</a></li>
857db96d56Sopenharmony_ci<li><a class="reference internal" href="#window-menu-shell-and-editor">Window menu (Shell and Editor)</a></li>
867db96d56Sopenharmony_ci<li><a class="reference internal" href="#help-menu-shell-and-editor">Help menu (Shell and Editor)</a></li>
877db96d56Sopenharmony_ci<li><a class="reference internal" href="#context-menus">Context menus</a></li>
887db96d56Sopenharmony_ci</ul>
897db96d56Sopenharmony_ci</li>
907db96d56Sopenharmony_ci<li><a class="reference internal" href="#editing-and-navigation">Editing and Navigation</a><ul>
917db96d56Sopenharmony_ci<li><a class="reference internal" href="#editor-windows">Editor windows</a></li>
927db96d56Sopenharmony_ci<li><a class="reference internal" href="#key-bindings">Key bindings</a></li>
937db96d56Sopenharmony_ci<li><a class="reference internal" href="#automatic-indentation">Automatic indentation</a></li>
947db96d56Sopenharmony_ci<li><a class="reference internal" href="#search-and-replace">Search and Replace</a></li>
957db96d56Sopenharmony_ci<li><a class="reference internal" href="#completions">Completions</a></li>
967db96d56Sopenharmony_ci<li><a class="reference internal" href="#calltips">Calltips</a></li>
977db96d56Sopenharmony_ci<li><a class="reference internal" href="#code-context">Code Context</a></li>
987db96d56Sopenharmony_ci<li><a class="reference internal" href="#shell-window">Shell window</a></li>
997db96d56Sopenharmony_ci<li><a class="reference internal" href="#text-colors">Text colors</a></li>
1007db96d56Sopenharmony_ci</ul>
1017db96d56Sopenharmony_ci</li>
1027db96d56Sopenharmony_ci<li><a class="reference internal" href="#startup-and-code-execution">Startup and Code Execution</a><ul>
1037db96d56Sopenharmony_ci<li><a class="reference internal" href="#command-line-usage">Command line usage</a></li>
1047db96d56Sopenharmony_ci<li><a class="reference internal" href="#startup-failure">Startup failure</a></li>
1057db96d56Sopenharmony_ci<li><a class="reference internal" href="#running-user-code">Running user code</a></li>
1067db96d56Sopenharmony_ci<li><a class="reference internal" href="#user-output-in-shell">User output in Shell</a></li>
1077db96d56Sopenharmony_ci<li><a class="reference internal" href="#developing-tkinter-applications">Developing tkinter applications</a></li>
1087db96d56Sopenharmony_ci<li><a class="reference internal" href="#running-without-a-subprocess">Running without a subprocess</a></li>
1097db96d56Sopenharmony_ci</ul>
1107db96d56Sopenharmony_ci</li>
1117db96d56Sopenharmony_ci<li><a class="reference internal" href="#help-and-preferences">Help and Preferences</a><ul>
1127db96d56Sopenharmony_ci<li><a class="reference internal" href="#help-sources">Help sources</a></li>
1137db96d56Sopenharmony_ci<li><a class="reference internal" href="#setting-preferences">Setting preferences</a></li>
1147db96d56Sopenharmony_ci<li><a class="reference internal" href="#idle-on-macos">IDLE on macOS</a></li>
1157db96d56Sopenharmony_ci<li><a class="reference internal" href="#extensions">Extensions</a></li>
1167db96d56Sopenharmony_ci</ul>
1177db96d56Sopenharmony_ci</li>
1187db96d56Sopenharmony_ci<li><a class="reference internal" href="#module-idlelib">idlelib</a></li>
1197db96d56Sopenharmony_ci</ul>
1207db96d56Sopenharmony_ci</li>
1217db96d56Sopenharmony_ci</ul>
1227db96d56Sopenharmony_ci
1237db96d56Sopenharmony_ci  </div>
1247db96d56Sopenharmony_ci  <div>
1257db96d56Sopenharmony_ci    <h4>Previous topic</h4>
1267db96d56Sopenharmony_ci    <p class="topless"><a href="tkinter.tix.html"
1277db96d56Sopenharmony_ci                          title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.tix</span></code> — Extension widgets for Tk</a></p>
1287db96d56Sopenharmony_ci  </div>
1297db96d56Sopenharmony_ci  <div>
1307db96d56Sopenharmony_ci    <h4>Next topic</h4>
1317db96d56Sopenharmony_ci    <p class="topless"><a href="development.html"
1327db96d56Sopenharmony_ci                          title="next chapter">Development Tools</a></p>
1337db96d56Sopenharmony_ci  </div>
1347db96d56Sopenharmony_ci  <div role="note" aria-label="source link">
1357db96d56Sopenharmony_ci    <h3>This Page</h3>
1367db96d56Sopenharmony_ci    <ul class="this-page-menu">
1377db96d56Sopenharmony_ci      <li><a href="../bugs.html">Report a Bug</a></li>
1387db96d56Sopenharmony_ci      <li>
1397db96d56Sopenharmony_ci        <a href="https://github.com/python/cpython/blob/main/Doc/library/idle.rst"
1407db96d56Sopenharmony_ci            rel="nofollow">Show Source
1417db96d56Sopenharmony_ci        </a>
1427db96d56Sopenharmony_ci      </li>
1437db96d56Sopenharmony_ci    </ul>
1447db96d56Sopenharmony_ci  </div>
1457db96d56Sopenharmony_ci        </nav>
1467db96d56Sopenharmony_ci    </div>
1477db96d56Sopenharmony_ci</div>
1487db96d56Sopenharmony_ci
1497db96d56Sopenharmony_ci
1507db96d56Sopenharmony_ci    <div class="related" role="navigation" aria-label="related navigation">
1517db96d56Sopenharmony_ci      <h3>Navigation</h3>
1527db96d56Sopenharmony_ci      <ul>
1537db96d56Sopenharmony_ci        <li class="right" style="margin-right: 10px">
1547db96d56Sopenharmony_ci          <a href="../genindex.html" title="General Index"
1557db96d56Sopenharmony_ci             accesskey="I">index</a></li>
1567db96d56Sopenharmony_ci        <li class="right" >
1577db96d56Sopenharmony_ci          <a href="../py-modindex.html" title="Python Module Index"
1587db96d56Sopenharmony_ci             >modules</a> |</li>
1597db96d56Sopenharmony_ci        <li class="right" >
1607db96d56Sopenharmony_ci          <a href="development.html" title="Development Tools"
1617db96d56Sopenharmony_ci             accesskey="N">next</a> |</li>
1627db96d56Sopenharmony_ci        <li class="right" >
1637db96d56Sopenharmony_ci          <a href="tkinter.tix.html" title="tkinter.tix — Extension widgets for Tk"
1647db96d56Sopenharmony_ci             accesskey="P">previous</a> |</li>
1657db96d56Sopenharmony_ci
1667db96d56Sopenharmony_ci          <li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
1677db96d56Sopenharmony_ci          <li><a href="https://www.python.org/">Python</a> &#187;</li>
1687db96d56Sopenharmony_ci          <li class="switchers">
1697db96d56Sopenharmony_ci            <div class="language_switcher_placeholder"></div>
1707db96d56Sopenharmony_ci            <div class="version_switcher_placeholder"></div>
1717db96d56Sopenharmony_ci          </li>
1727db96d56Sopenharmony_ci          <li>
1737db96d56Sopenharmony_ci
1747db96d56Sopenharmony_ci          </li>
1757db96d56Sopenharmony_ci    <li id="cpython-language-and-version">
1767db96d56Sopenharmony_ci      <a href="../index.html">3.12.0a0 Documentation</a> &#187;
1777db96d56Sopenharmony_ci    </li>
1787db96d56Sopenharmony_ci
1797db96d56Sopenharmony_ci          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
1807db96d56Sopenharmony_ci          <li class="nav-item nav-item-2"><a href="tk.html" accesskey="U">Graphical User Interfaces with Tk</a> &#187;</li>
1817db96d56Sopenharmony_ci        <li class="nav-item nav-item-this"><a href="">IDLE</a></li>
1827db96d56Sopenharmony_ci                <li class="right">
1837db96d56Sopenharmony_ci
1847db96d56Sopenharmony_ci
1857db96d56Sopenharmony_ci    <div class="inline-search" role="search">
1867db96d56Sopenharmony_ci        <form class="inline-search" action="../search.html" method="get">
1877db96d56Sopenharmony_ci          <input placeholder="Quick search" aria-label="Quick search" type="text" name="q" />
1887db96d56Sopenharmony_ci          <input type="submit" value="Go" />
1897db96d56Sopenharmony_ci          <input type="hidden" name="check_keywords" value="yes" />
1907db96d56Sopenharmony_ci          <input type="hidden" name="area" value="default" />
1917db96d56Sopenharmony_ci        </form>
1927db96d56Sopenharmony_ci    </div>
1937db96d56Sopenharmony_ci                     |
1947db96d56Sopenharmony_ci                </li>
1957db96d56Sopenharmony_ci
1967db96d56Sopenharmony_ci      </ul>
1977db96d56Sopenharmony_ci    </div>
1987db96d56Sopenharmony_ci
1997db96d56Sopenharmony_ci    <div class="document">
2007db96d56Sopenharmony_ci      <div class="documentwrapper">
2017db96d56Sopenharmony_ci        <div class="bodywrapper">
2027db96d56Sopenharmony_ci          <div class="body" role="main">
2037db96d56Sopenharmony_ci
2047db96d56Sopenharmony_ci  <section id="idle">
2057db96d56Sopenharmony_ci<span id="id1"></span><h1>IDLE<a class="headerlink" href="#idle" title="Permalink to this heading">¶</a></h1>
2067db96d56Sopenharmony_ci<p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/main/Lib/idlelib/">Lib/idlelib/</a></p>
2077db96d56Sopenharmony_ci<hr class="docutils" id="index-0" />
2087db96d56Sopenharmony_ci<p>IDLE is Python’s Integrated Development and Learning Environment.</p>
2097db96d56Sopenharmony_ci<p>IDLE has the following features:</p>
2107db96d56Sopenharmony_ci<ul class="simple">
2117db96d56Sopenharmony_ci<li><p>coded in 100% pure Python, using the <a class="reference internal" href="tkinter.html#module-tkinter" title="tkinter: Interface to Tcl/Tk for graphical user interfaces"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code></a> GUI toolkit</p></li>
2127db96d56Sopenharmony_ci<li><p>cross-platform: works mostly the same on Windows, Unix, and macOS</p></li>
2137db96d56Sopenharmony_ci<li><p>Python shell window (interactive interpreter) with colorizing
2147db96d56Sopenharmony_ciof code input, output, and error messages</p></li>
2157db96d56Sopenharmony_ci<li><p>multi-window text editor with multiple undo, Python colorizing,
2167db96d56Sopenharmony_cismart indent, call tips, auto completion, and other features</p></li>
2177db96d56Sopenharmony_ci<li><p>search within any window, replace within editor windows, and search
2187db96d56Sopenharmony_cithrough multiple files (grep)</p></li>
2197db96d56Sopenharmony_ci<li><p>debugger with persistent breakpoints, stepping, and viewing
2207db96d56Sopenharmony_ciof global and local namespaces</p></li>
2217db96d56Sopenharmony_ci<li><p>configuration, browsers, and other dialogs</p></li>
2227db96d56Sopenharmony_ci</ul>
2237db96d56Sopenharmony_ci<section id="menus">
2247db96d56Sopenharmony_ci<h2>Menus<a class="headerlink" href="#menus" title="Permalink to this heading">¶</a></h2>
2257db96d56Sopenharmony_ci<p>IDLE has two main window types, the Shell window and the Editor window.  It is
2267db96d56Sopenharmony_cipossible to have multiple editor windows simultaneously.  On Windows and
2277db96d56Sopenharmony_ciLinux, each has its own top menu.  Each menu documented below indicates
2287db96d56Sopenharmony_ciwhich window type it is associated with.</p>
2297db96d56Sopenharmony_ci<p>Output windows, such as used for Edit =&gt; Find in Files, are a subtype of editor
2307db96d56Sopenharmony_ciwindow.  They currently have the same top menu but a different
2317db96d56Sopenharmony_cidefault title and context menu.</p>
2327db96d56Sopenharmony_ci<p>On macOS, there is one application menu.  It dynamically changes according
2337db96d56Sopenharmony_cito the window currently selected.  It has an IDLE menu, and some entries
2347db96d56Sopenharmony_cidescribed below are moved around to conform to Apple guidelines.</p>
2357db96d56Sopenharmony_ci<section id="file-menu-shell-and-editor">
2367db96d56Sopenharmony_ci<h3>File menu (Shell and Editor)<a class="headerlink" href="#file-menu-shell-and-editor" title="Permalink to this heading">¶</a></h3>
2377db96d56Sopenharmony_ci<dl class="simple">
2387db96d56Sopenharmony_ci<dt>New File</dt><dd><p>Create a new file editing window.</p>
2397db96d56Sopenharmony_ci</dd>
2407db96d56Sopenharmony_ci<dt>Open…</dt><dd><p>Open an existing file with an Open dialog.</p>
2417db96d56Sopenharmony_ci</dd>
2427db96d56Sopenharmony_ci<dt>Open Module…</dt><dd><p>Open an existing module (searches sys.path).</p>
2437db96d56Sopenharmony_ci</dd>
2447db96d56Sopenharmony_ci<dt>Recent Files</dt><dd><p>Open a list of recent files.  Click one to open it.</p>
2457db96d56Sopenharmony_ci</dd>
2467db96d56Sopenharmony_ci</dl>
2477db96d56Sopenharmony_ci<dl class="simple" id="index-1">
2487db96d56Sopenharmony_ci<dt>Module Browser</dt><dd><p>Show functions, classes, and methods in the current Editor file in a
2497db96d56Sopenharmony_citree structure.  In the shell, open a module first.</p>
2507db96d56Sopenharmony_ci</dd>
2517db96d56Sopenharmony_ci<dt>Path Browser</dt><dd><p>Show sys.path directories, modules, functions, classes and methods in a
2527db96d56Sopenharmony_citree structure.</p>
2537db96d56Sopenharmony_ci</dd>
2547db96d56Sopenharmony_ci<dt>Save</dt><dd><p>Save the current window to the associated file, if there is one.  Windows
2557db96d56Sopenharmony_cithat have been changed since being opened or last saved have a * before
2567db96d56Sopenharmony_ciand after the window title.  If there is no associated file,
2577db96d56Sopenharmony_cido Save As instead.</p>
2587db96d56Sopenharmony_ci</dd>
2597db96d56Sopenharmony_ci<dt>Save As…</dt><dd><p>Save the current window with a Save As dialog.  The file saved becomes the
2607db96d56Sopenharmony_cinew associated file for the window. (If your file namager is set to hide
2617db96d56Sopenharmony_ciextensions, the current extension will be omitted in the file name box.
2627db96d56Sopenharmony_ciIf the new filename has no ‘.’, ‘.py’ and ‘.txt’ will be added for Python
2637db96d56Sopenharmony_ciand text files, except that on macOS Aqua,’.py’ is added for all files.)</p>
2647db96d56Sopenharmony_ci</dd>
2657db96d56Sopenharmony_ci<dt>Save Copy As…</dt><dd><p>Save the current window to different file without changing the associated
2667db96d56Sopenharmony_cifile.  (See Save As note above about filename extensions.)</p>
2677db96d56Sopenharmony_ci</dd>
2687db96d56Sopenharmony_ci<dt>Print Window</dt><dd><p>Print the current window to the default printer.</p>
2697db96d56Sopenharmony_ci</dd>
2707db96d56Sopenharmony_ci<dt>Close Window</dt><dd><p>Close the current window (if an unsaved editor, ask to save; if an unsaved
2717db96d56Sopenharmony_ciShell, 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
2727db96d56Sopenharmony_ciwindow also closes Shell.  If this is the only window, also exit IDLE.</p>
2737db96d56Sopenharmony_ci</dd>
2747db96d56Sopenharmony_ci<dt>Exit IDLE</dt><dd><p>Close all windows and quit IDLE (ask to save unsaved edit windows).</p>
2757db96d56Sopenharmony_ci</dd>
2767db96d56Sopenharmony_ci</dl>
2777db96d56Sopenharmony_ci</section>
2787db96d56Sopenharmony_ci<section id="edit-menu-shell-and-editor">
2797db96d56Sopenharmony_ci<h3>Edit menu (Shell and Editor)<a class="headerlink" href="#edit-menu-shell-and-editor" title="Permalink to this heading">¶</a></h3>
2807db96d56Sopenharmony_ci<dl class="simple">
2817db96d56Sopenharmony_ci<dt>Undo</dt><dd><p>Undo the last change to the current window.  A maximum of 1000 changes may
2827db96d56Sopenharmony_cibe undone.</p>
2837db96d56Sopenharmony_ci</dd>
2847db96d56Sopenharmony_ci<dt>Redo</dt><dd><p>Redo the last undone change to the current window.</p>
2857db96d56Sopenharmony_ci</dd>
2867db96d56Sopenharmony_ci<dt>Select All</dt><dd><p>Select the entire contents of the current window.</p>
2877db96d56Sopenharmony_ci</dd>
2887db96d56Sopenharmony_ci<dt>Cut</dt><dd><p>Copy selection into the system-wide clipboard; then delete the selection.</p>
2897db96d56Sopenharmony_ci</dd>
2907db96d56Sopenharmony_ci<dt>Copy</dt><dd><p>Copy selection into the system-wide clipboard.</p>
2917db96d56Sopenharmony_ci</dd>
2927db96d56Sopenharmony_ci<dt>Paste</dt><dd><p>Insert contents of the system-wide clipboard into the current window.</p>
2937db96d56Sopenharmony_ci</dd>
2947db96d56Sopenharmony_ci</dl>
2957db96d56Sopenharmony_ci<p>The clipboard functions are also available in context menus.</p>
2967db96d56Sopenharmony_ci<dl class="simple">
2977db96d56Sopenharmony_ci<dt>Find…</dt><dd><p>Open a search dialog with many options</p>
2987db96d56Sopenharmony_ci</dd>
2997db96d56Sopenharmony_ci<dt>Find Again</dt><dd><p>Repeat the last search, if there is one.</p>
3007db96d56Sopenharmony_ci</dd>
3017db96d56Sopenharmony_ci<dt>Find Selection</dt><dd><p>Search for the currently selected string, if there is one.</p>
3027db96d56Sopenharmony_ci</dd>
3037db96d56Sopenharmony_ci<dt>Find in Files…</dt><dd><p>Open a file search dialog.  Put results in a new output window.</p>
3047db96d56Sopenharmony_ci</dd>
3057db96d56Sopenharmony_ci<dt>Replace…</dt><dd><p>Open a search-and-replace dialog.</p>
3067db96d56Sopenharmony_ci</dd>
3077db96d56Sopenharmony_ci<dt>Go to Line</dt><dd><p>Move the cursor to the beginning of the line requested and make that
3087db96d56Sopenharmony_ciline visible.  A request past the end of the file goes to the end.
3097db96d56Sopenharmony_ciClear any selection and update the line and column status.</p>
3107db96d56Sopenharmony_ci</dd>
3117db96d56Sopenharmony_ci<dt>Show Completions</dt><dd><p>Open a scrollable list allowing selection of existing names. See
3127db96d56Sopenharmony_ci<a class="reference internal" href="#completions"><span class="std std-ref">Completions</span></a> in the Editing and navigation section below.</p>
3137db96d56Sopenharmony_ci</dd>
3147db96d56Sopenharmony_ci<dt>Expand Word</dt><dd><p>Expand a prefix you have typed to match a full word in the same window;
3157db96d56Sopenharmony_cirepeat to get a different expansion.</p>
3167db96d56Sopenharmony_ci</dd>
3177db96d56Sopenharmony_ci<dt>Show Call Tip</dt><dd><p>After an unclosed parenthesis for a function, open a small window with
3187db96d56Sopenharmony_cifunction parameter hints.  See <a class="reference internal" href="#calltips"><span class="std std-ref">Calltips</span></a> in the
3197db96d56Sopenharmony_ciEditing and navigation section below.</p>
3207db96d56Sopenharmony_ci</dd>
3217db96d56Sopenharmony_ci<dt>Show Surrounding Parens</dt><dd><p>Highlight the surrounding parenthesis.</p>
3227db96d56Sopenharmony_ci</dd>
3237db96d56Sopenharmony_ci</dl>
3247db96d56Sopenharmony_ci</section>
3257db96d56Sopenharmony_ci<section id="format-menu-editor-window-only">
3267db96d56Sopenharmony_ci<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>
3277db96d56Sopenharmony_ci<dl class="simple">
3287db96d56Sopenharmony_ci<dt>Format Paragraph</dt><dd><p>Reformat the current blank-line-delimited paragraph in comment block or
3297db96d56Sopenharmony_cimultiline string or selected line in a string.  All lines in the
3307db96d56Sopenharmony_ciparagraph will be formatted to less than N columns, where N defaults to 72.</p>
3317db96d56Sopenharmony_ci</dd>
3327db96d56Sopenharmony_ci<dt>Indent Region</dt><dd><p>Shift selected lines right by the indent width (default 4 spaces).</p>
3337db96d56Sopenharmony_ci</dd>
3347db96d56Sopenharmony_ci<dt>Dedent Region</dt><dd><p>Shift selected lines left by the indent width (default 4 spaces).</p>
3357db96d56Sopenharmony_ci</dd>
3367db96d56Sopenharmony_ci<dt>Comment Out Region</dt><dd><p>Insert ## in front of selected lines.</p>
3377db96d56Sopenharmony_ci</dd>
3387db96d56Sopenharmony_ci<dt>Uncomment Region</dt><dd><p>Remove leading # or ## from selected lines.</p>
3397db96d56Sopenharmony_ci</dd>
3407db96d56Sopenharmony_ci<dt>Tabify Region</dt><dd><p>Turn <em>leading</em> stretches of spaces into tabs. (Note: We recommend using
3417db96d56Sopenharmony_ci4 space blocks to indent Python code.)</p>
3427db96d56Sopenharmony_ci</dd>
3437db96d56Sopenharmony_ci<dt>Untabify Region</dt><dd><p>Turn <em>all</em> tabs into the correct number of spaces.</p>
3447db96d56Sopenharmony_ci</dd>
3457db96d56Sopenharmony_ci<dt>Toggle Tabs</dt><dd><p>Open a dialog to switch between indenting with spaces and tabs.</p>
3467db96d56Sopenharmony_ci</dd>
3477db96d56Sopenharmony_ci<dt>New Indent Width</dt><dd><p>Open a dialog to change indent width. The accepted default by the Python
3487db96d56Sopenharmony_cicommunity is 4 spaces.</p>
3497db96d56Sopenharmony_ci</dd>
3507db96d56Sopenharmony_ci<dt>Strip Trailing Chitespace</dt><dd><p>Remove trailing space and other whitespace characters after the last
3517db96d56Sopenharmony_cinon-whitespace character of a line by applying str.rstrip to each line,
3527db96d56Sopenharmony_ciincluding lines within multiline strings.  Except for Shell windows,
3537db96d56Sopenharmony_ciremove extra newlines at the end of the file.</p>
3547db96d56Sopenharmony_ci</dd>
3557db96d56Sopenharmony_ci</dl>
3567db96d56Sopenharmony_ci</section>
3577db96d56Sopenharmony_ci<section id="run-menu-editor-window-only">
3587db96d56Sopenharmony_ci<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>
3597db96d56Sopenharmony_ci<dl class="simple" id="run-module">
3607db96d56Sopenharmony_ci<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
3617db96d56Sopenharmony_cienvironment, then execute the module.  Output is displayed in the Shell
3627db96d56Sopenharmony_ciwindow.  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>.
3637db96d56Sopenharmony_ciWhen execution is complete, the Shell retains focus and displays a prompt.
3647db96d56Sopenharmony_ciAt this point, one may interactively explore the result of execution.
3657db96d56Sopenharmony_ciThis 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
3667db96d56Sopenharmony_ciline.</p>
3677db96d56Sopenharmony_ci</dd>
3687db96d56Sopenharmony_ci</dl>
3697db96d56Sopenharmony_ci<dl class="simple" id="run-custom">
3707db96d56Sopenharmony_ci<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
3717db96d56Sopenharmony_cisettings.  <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
3727db96d56Sopenharmony_cion a command line. The module can be run in the Shell without restarting.</p>
3737db96d56Sopenharmony_ci</dd>
3747db96d56Sopenharmony_ci</dl>
3757db96d56Sopenharmony_ci<dl class="simple" id="check-module">
3767db96d56Sopenharmony_ci<dt>Check Module</dt><dd><p>Check the syntax of the module currently open in the Editor window. If the
3777db96d56Sopenharmony_cimodule has not been saved IDLE will either prompt the user to save or
3787db96d56Sopenharmony_ciautosave, as selected in the General tab of the Idle Settings dialog.  If
3797db96d56Sopenharmony_cithere is a syntax error, the approximate location is indicated in the
3807db96d56Sopenharmony_ciEditor window.</p>
3817db96d56Sopenharmony_ci</dd>
3827db96d56Sopenharmony_ci</dl>
3837db96d56Sopenharmony_ci<dl class="simple" id="python-shell">
3847db96d56Sopenharmony_ci<dt>Python Shell</dt><dd><p>Open or wake up the Python Shell window.</p>
3857db96d56Sopenharmony_ci</dd>
3867db96d56Sopenharmony_ci</dl>
3877db96d56Sopenharmony_ci</section>
3887db96d56Sopenharmony_ci<section id="shell-menu-shell-window-only">
3897db96d56Sopenharmony_ci<h3>Shell menu (Shell window only)<a class="headerlink" href="#shell-menu-shell-window-only" title="Permalink to this heading">¶</a></h3>
3907db96d56Sopenharmony_ci<dl class="simple">
3917db96d56Sopenharmony_ci<dt>View Last Restart</dt><dd><p>Scroll the shell window to the last Shell restart.</p>
3927db96d56Sopenharmony_ci</dd>
3937db96d56Sopenharmony_ci<dt>Restart Shell</dt><dd><p>Restart the shell to clean the environment and reset display and exception handling.</p>
3947db96d56Sopenharmony_ci</dd>
3957db96d56Sopenharmony_ci<dt>Previous History</dt><dd><p>Cycle through earlier commands in history which match the current entry.</p>
3967db96d56Sopenharmony_ci</dd>
3977db96d56Sopenharmony_ci<dt>Next History</dt><dd><p>Cycle through later commands in history which match the current entry.</p>
3987db96d56Sopenharmony_ci</dd>
3997db96d56Sopenharmony_ci<dt>Interrupt Execution</dt><dd><p>Stop a running program.</p>
4007db96d56Sopenharmony_ci</dd>
4017db96d56Sopenharmony_ci</dl>
4027db96d56Sopenharmony_ci</section>
4037db96d56Sopenharmony_ci<section id="debug-menu-shell-window-only">
4047db96d56Sopenharmony_ci<h3>Debug menu (Shell window only)<a class="headerlink" href="#debug-menu-shell-window-only" title="Permalink to this heading">¶</a></h3>
4057db96d56Sopenharmony_ci<dl class="simple">
4067db96d56Sopenharmony_ci<dt>Go to File/Line</dt><dd><p>Look on the current line. with the cursor, and the line above for a filename
4077db96d56Sopenharmony_ciand line number.  If found, open the file if not already open, and show the
4087db96d56Sopenharmony_ciline.  Use this to view source lines referenced in an exception traceback
4097db96d56Sopenharmony_ciand lines found by Find in Files. Also available in the context menu of
4107db96d56Sopenharmony_cithe Shell window and Output windows.</p>
4117db96d56Sopenharmony_ci</dd>
4127db96d56Sopenharmony_ci</dl>
4137db96d56Sopenharmony_ci<dl class="simple" id="index-3">
4147db96d56Sopenharmony_ci<dt>Debugger (toggle)</dt><dd><p>When activated, code entered in the Shell or run from an Editor will run
4157db96d56Sopenharmony_ciunder the debugger.  In the Editor, breakpoints can be set with the context
4167db96d56Sopenharmony_cimenu.  This feature is still incomplete and somewhat experimental.</p>
4177db96d56Sopenharmony_ci</dd>
4187db96d56Sopenharmony_ci<dt>Stack Viewer</dt><dd><p>Show the stack traceback of the last exception in a tree widget, with
4197db96d56Sopenharmony_ciaccess to locals and globals.</p>
4207db96d56Sopenharmony_ci</dd>
4217db96d56Sopenharmony_ci<dt>Auto-open Stack Viewer</dt><dd><p>Toggle automatically opening the stack viewer on an unhandled exception.</p>
4227db96d56Sopenharmony_ci</dd>
4237db96d56Sopenharmony_ci</dl>
4247db96d56Sopenharmony_ci</section>
4257db96d56Sopenharmony_ci<section id="options-menu-shell-and-editor">
4267db96d56Sopenharmony_ci<h3>Options menu (Shell and Editor)<a class="headerlink" href="#options-menu-shell-and-editor" title="Permalink to this heading">¶</a></h3>
4277db96d56Sopenharmony_ci<dl class="simple">
4287db96d56Sopenharmony_ci<dt>Configure IDLE</dt><dd><p>Open a configuration dialog and change preferences for the following:
4297db96d56Sopenharmony_cifonts, indentation, keybindings, text color themes, startup windows and
4307db96d56Sopenharmony_cisize, additional help sources, and extensions.  On macOS, open the
4317db96d56Sopenharmony_ciconfiguration dialog by selecting Preferences in the application
4327db96d56Sopenharmony_cimenu. For more details, see
4337db96d56Sopenharmony_ci<a class="reference internal" href="#preferences"><span class="std std-ref">Setting preferences</span></a> under Help and preferences.</p>
4347db96d56Sopenharmony_ci</dd>
4357db96d56Sopenharmony_ci</dl>
4367db96d56Sopenharmony_ci<p>Most configuration options apply to all windows or all future windows.
4377db96d56Sopenharmony_ciThe option items below only apply to the active window.</p>
4387db96d56Sopenharmony_ci<dl class="simple">
4397db96d56Sopenharmony_ci<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
4407db96d56Sopenharmony_ciof the code which has scrolled above the top of the window.  See
4417db96d56Sopenharmony_ci<a class="reference internal" href="#code-context"><span class="std std-ref">Code Context</span></a> in the Editing and Navigation section
4427db96d56Sopenharmony_cibelow.</p>
4437db96d56Sopenharmony_ci</dd>
4447db96d56Sopenharmony_ci<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
4457db96d56Sopenharmony_ciof each line of text.  The default is off, which may be changed in the
4467db96d56Sopenharmony_cipreferences (see <a class="reference internal" href="#preferences"><span class="std std-ref">Setting preferences</span></a>).</p>
4477db96d56Sopenharmony_ci</dd>
4487db96d56Sopenharmony_ci<dt>Zoom/Restore Height</dt><dd><p>Toggles the window between normal size and maximum height. The initial size
4497db96d56Sopenharmony_cidefaults to 40 lines by 80 chars unless changed on the General tab of the
4507db96d56Sopenharmony_ciConfigure IDLE dialog.  The maximum height for a screen is determined by
4517db96d56Sopenharmony_cimomentarily maximizing a window the first time one is zoomed on the screen.
4527db96d56Sopenharmony_ciChanging screen settings may invalidate the saved height.  This toggle has
4537db96d56Sopenharmony_cino effect when a window is maximized.</p>
4547db96d56Sopenharmony_ci</dd>
4557db96d56Sopenharmony_ci</dl>
4567db96d56Sopenharmony_ci</section>
4577db96d56Sopenharmony_ci<section id="window-menu-shell-and-editor">
4587db96d56Sopenharmony_ci<h3>Window menu (Shell and Editor)<a class="headerlink" href="#window-menu-shell-and-editor" title="Permalink to this heading">¶</a></h3>
4597db96d56Sopenharmony_ci<p>Lists the names of all open windows; select one to bring it to the foreground
4607db96d56Sopenharmony_ci(deiconifying it if necessary).</p>
4617db96d56Sopenharmony_ci</section>
4627db96d56Sopenharmony_ci<section id="help-menu-shell-and-editor">
4637db96d56Sopenharmony_ci<h3>Help menu (Shell and Editor)<a class="headerlink" href="#help-menu-shell-and-editor" title="Permalink to this heading">¶</a></h3>
4647db96d56Sopenharmony_ci<dl class="simple">
4657db96d56Sopenharmony_ci<dt>About IDLE</dt><dd><p>Display version, copyright, license, credits, and more.</p>
4667db96d56Sopenharmony_ci</dd>
4677db96d56Sopenharmony_ci<dt>IDLE Help</dt><dd><p>Display this IDLE document, detailing the menu options, basic editing and
4687db96d56Sopenharmony_cinavigation, and other tips.</p>
4697db96d56Sopenharmony_ci</dd>
4707db96d56Sopenharmony_ci<dt>Python Docs</dt><dd><p>Access local Python documentation, if installed, or start a web browser
4717db96d56Sopenharmony_ciand open docs.python.org showing the latest Python documentation.</p>
4727db96d56Sopenharmony_ci</dd>
4737db96d56Sopenharmony_ci<dt>Turtle Demo</dt><dd><p>Run the turtledemo module with example Python code and turtle drawings.</p>
4747db96d56Sopenharmony_ci</dd>
4757db96d56Sopenharmony_ci</dl>
4767db96d56Sopenharmony_ci<p>Additional help sources may be added here with the Configure IDLE dialog under
4777db96d56Sopenharmony_cithe General tab. See the <a class="reference internal" href="#help-sources"><span class="std std-ref">Help sources</span></a> subsection below
4787db96d56Sopenharmony_cifor more on Help menu choices.</p>
4797db96d56Sopenharmony_ci</section>
4807db96d56Sopenharmony_ci<section id="context-menus">
4817db96d56Sopenharmony_ci<span id="index-4"></span><h3>Context menus<a class="headerlink" href="#context-menus" title="Permalink to this heading">¶</a></h3>
4827db96d56Sopenharmony_ci<p>Open a context menu by right-clicking in a window (Control-click on macOS).
4837db96d56Sopenharmony_ciContext menus have the standard clipboard functions also on the Edit menu.</p>
4847db96d56Sopenharmony_ci<dl class="simple">
4857db96d56Sopenharmony_ci<dt>Cut</dt><dd><p>Copy selection into the system-wide clipboard; then delete the selection.</p>
4867db96d56Sopenharmony_ci</dd>
4877db96d56Sopenharmony_ci<dt>Copy</dt><dd><p>Copy selection into the system-wide clipboard.</p>
4887db96d56Sopenharmony_ci</dd>
4897db96d56Sopenharmony_ci<dt>Paste</dt><dd><p>Insert contents of the system-wide clipboard into the current window.</p>
4907db96d56Sopenharmony_ci</dd>
4917db96d56Sopenharmony_ci</dl>
4927db96d56Sopenharmony_ci<p>Editor windows also have breakpoint functions.  Lines with a breakpoint set are
4937db96d56Sopenharmony_cispecially marked.  Breakpoints only have an effect when running under the
4947db96d56Sopenharmony_cidebugger.  Breakpoints for a file are saved in the user’s <code class="docutils literal notranslate"><span class="pre">.idlerc</span></code>
4957db96d56Sopenharmony_cidirectory.</p>
4967db96d56Sopenharmony_ci<dl class="simple">
4977db96d56Sopenharmony_ci<dt>Set Breakpoint</dt><dd><p>Set a breakpoint on the current line.</p>
4987db96d56Sopenharmony_ci</dd>
4997db96d56Sopenharmony_ci<dt>Clear Breakpoint</dt><dd><p>Clear the breakpoint on that line.</p>
5007db96d56Sopenharmony_ci</dd>
5017db96d56Sopenharmony_ci</dl>
5027db96d56Sopenharmony_ci<p>Shell and Output windows also have the following.</p>
5037db96d56Sopenharmony_ci<dl class="simple">
5047db96d56Sopenharmony_ci<dt>Go to file/line</dt><dd><p>Same as in Debug menu.</p>
5057db96d56Sopenharmony_ci</dd>
5067db96d56Sopenharmony_ci</dl>
5077db96d56Sopenharmony_ci<p>The Shell window also has an output squeezing facility explained in the <em>Python
5087db96d56Sopenharmony_ciShell window</em> subsection below.</p>
5097db96d56Sopenharmony_ci<dl class="simple">
5107db96d56Sopenharmony_ci<dt>Squeeze</dt><dd><p>If the cursor is over an output line, squeeze all the output between
5117db96d56Sopenharmony_cithe code above and the prompt below down to a ‘Squeezed text’ label.</p>
5127db96d56Sopenharmony_ci</dd>
5137db96d56Sopenharmony_ci</dl>
5147db96d56Sopenharmony_ci</section>
5157db96d56Sopenharmony_ci</section>
5167db96d56Sopenharmony_ci<section id="editing-and-navigation">
5177db96d56Sopenharmony_ci<span id="id2"></span><h2>Editing and Navigation<a class="headerlink" href="#editing-and-navigation" title="Permalink to this heading">¶</a></h2>
5187db96d56Sopenharmony_ci<section id="editor-windows">
5197db96d56Sopenharmony_ci<h3>Editor windows<a class="headerlink" href="#editor-windows" title="Permalink to this heading">¶</a></h3>
5207db96d56Sopenharmony_ci<p>IDLE may open editor windows when it starts, depending on settings
5217db96d56Sopenharmony_ciand how you start IDLE.  Thereafter, use the File menu.  There can be only
5227db96d56Sopenharmony_cione open editor window for a given file.</p>
5237db96d56Sopenharmony_ci<p>The title bar contains the name of the file, the full path, and the version
5247db96d56Sopenharmony_ciof Python and IDLE running the window.  The status bar contains the line
5257db96d56Sopenharmony_cinumber (‘Ln’) and column number (‘Col’).  Line numbers start with 1;
5267db96d56Sopenharmony_cicolumn numbers with 0.</p>
5277db96d56Sopenharmony_ci<p>IDLE assumes that files with a known .py* extension contain Python code
5287db96d56Sopenharmony_ciand that other files do not.  Run Python code with the Run menu.</p>
5297db96d56Sopenharmony_ci</section>
5307db96d56Sopenharmony_ci<section id="key-bindings">
5317db96d56Sopenharmony_ci<h3>Key bindings<a class="headerlink" href="#key-bindings" title="Permalink to this heading">¶</a></h3>
5327db96d56Sopenharmony_ci<p>In this section, ‘C’ refers to the <kbd class="kbd docutils literal notranslate">Control</kbd> key on Windows and Unix and
5337db96d56Sopenharmony_cithe <kbd class="kbd docutils literal notranslate">Command</kbd> key on macOS.</p>
5347db96d56Sopenharmony_ci<ul>
5357db96d56Sopenharmony_ci<li><p><kbd class="kbd docutils literal notranslate">Backspace</kbd> deletes to the left; <kbd class="kbd docutils literal notranslate">Del</kbd> deletes to the right</p></li>
5367db96d56Sopenharmony_ci<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> delete word left; <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 word to the right</p></li>
5377db96d56Sopenharmony_ci<li><p>Arrow keys and <kbd class="kbd docutils literal notranslate">Page Up</kbd>/<kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">Page</kbd> <kbd class="kbd docutils literal notranslate">Down</kbd></kbd> to move around</p></li>
5387db96d56Sopenharmony_ci<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 by words</p></li>
5397db96d56Sopenharmony_ci<li><p><kbd class="kbd docutils literal notranslate">Home</kbd>/<kbd class="kbd docutils literal notranslate">End</kbd> go to begin/end of line</p></li>
5407db96d56Sopenharmony_ci<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>/<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 begin/end of file</p></li>
5417db96d56Sopenharmony_ci<li><p>Some useful Emacs bindings are inherited from Tcl/Tk:</p>
5427db96d56Sopenharmony_ci<blockquote>
5437db96d56Sopenharmony_ci<div><ul class="simple">
5447db96d56Sopenharmony_ci<li><p><kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">a</kbd></kbd> beginning of line</p></li>
5457db96d56Sopenharmony_ci<li><p><kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">e</kbd></kbd> end of line</p></li>
5467db96d56Sopenharmony_ci<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> kill line (but doesn’t put it in clipboard)</p></li>
5477db96d56Sopenharmony_ci<li><p><kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">l</kbd></kbd> center window around the insertion point</p></li>
5487db96d56Sopenharmony_ci<li><p><kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">b</kbd></kbd> go backward one character without deleting (usually you can
5497db96d56Sopenharmony_cialso use the cursor key for this)</p></li>
5507db96d56Sopenharmony_ci<li><p><kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">f</kbd></kbd> go forward one character without deleting (usually you can
5517db96d56Sopenharmony_cialso use the cursor key for this)</p></li>
5527db96d56Sopenharmony_ci<li><p><kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">p</kbd></kbd> go up one line (usually you can also use the cursor key for
5537db96d56Sopenharmony_cithis)</p></li>
5547db96d56Sopenharmony_ci<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> delete next character</p></li>
5557db96d56Sopenharmony_ci</ul>
5567db96d56Sopenharmony_ci</div></blockquote>
5577db96d56Sopenharmony_ci</li>
5587db96d56Sopenharmony_ci</ul>
5597db96d56Sopenharmony_ci<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)
5607db96d56Sopenharmony_cimay work.  Keybindings are selected in the Configure IDLE dialog.</p>
5617db96d56Sopenharmony_ci</section>
5627db96d56Sopenharmony_ci<section id="automatic-indentation">
5637db96d56Sopenharmony_ci<h3>Automatic indentation<a class="headerlink" href="#automatic-indentation" title="Permalink to this heading">¶</a></h3>
5647db96d56Sopenharmony_ci<p>After a block-opening statement, the next line is indented by 4 spaces (in the
5657db96d56Sopenharmony_ciPython Shell window by one tab).  After certain keywords (break, return etc.)
5667db96d56Sopenharmony_cithe next line is dedented.  In leading indentation, <kbd class="kbd docutils literal notranslate">Backspace</kbd> deletes up
5677db96d56Sopenharmony_cito 4 spaces if they are there. <kbd class="kbd docutils literal notranslate">Tab</kbd> inserts spaces (in the Python
5687db96d56Sopenharmony_ciShell window one tab), number depends on Indent width. Currently, tabs
5697db96d56Sopenharmony_ciare restricted to four spaces due to Tcl/Tk limitations.</p>
5707db96d56Sopenharmony_ci<p>See also the indent/dedent region commands on the
5717db96d56Sopenharmony_ci<a class="reference internal" href="#format-menu"><span class="std std-ref">Format menu</span></a>.</p>
5727db96d56Sopenharmony_ci</section>
5737db96d56Sopenharmony_ci<section id="search-and-replace">
5747db96d56Sopenharmony_ci<h3>Search and Replace<a class="headerlink" href="#search-and-replace" title="Permalink to this heading">¶</a></h3>
5757db96d56Sopenharmony_ci<p>Any selection becomes a search target.  However, only selections within
5767db96d56Sopenharmony_cia line work because searches are only performed within lines with the
5777db96d56Sopenharmony_citerminal newline removed.  If <code class="docutils literal notranslate"><span class="pre">[x]</span> <span class="pre">Regular</span> <span class="pre">expresion</span></code> is checked, the
5787db96d56Sopenharmony_citarget is interpreted according to the Python re module.</p>
5797db96d56Sopenharmony_ci</section>
5807db96d56Sopenharmony_ci<section id="completions">
5817db96d56Sopenharmony_ci<span id="id3"></span><h3>Completions<a class="headerlink" href="#completions" title="Permalink to this heading">¶</a></h3>
5827db96d56Sopenharmony_ci<p>Completions are supplied, when requested and available, for module
5837db96d56Sopenharmony_cinames, attributes of classes or functions, or filenames.  Each request
5847db96d56Sopenharmony_cimethod displays a completion box with existing names.  (See tab
5857db96d56Sopenharmony_cicompletions below for an exception.) For any box, change the name
5867db96d56Sopenharmony_cibeing completed and the item highlighted in the box by
5877db96d56Sopenharmony_cityping and deleting characters; by hitting <kbd class="kbd docutils literal notranslate">Up</kbd>, <kbd class="kbd docutils literal notranslate">Down</kbd>,
5887db96d56Sopenharmony_ci<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;
5897db96d56Sopenharmony_ciand by a single click within the box.  Close the box with <kbd class="kbd docutils literal notranslate">Escape</kbd>,
5907db96d56Sopenharmony_ci<kbd class="kbd docutils literal notranslate">Enter</kbd>, and double <kbd class="kbd docutils literal notranslate">Tab</kbd> keys or clicks outside the box.
5917db96d56Sopenharmony_ciA double click within the box selects and closes.</p>
5927db96d56Sopenharmony_ci<p>One way to open a box is to type a key character and wait for a
5937db96d56Sopenharmony_cipredefined interval.  This defaults to 2 seconds; customize it
5947db96d56Sopenharmony_ciin the settings dialog.  (To prevent auto popups, set the delay to a
5957db96d56Sopenharmony_cilarge number of milliseconds, such as 100000000.) For imported module
5967db96d56Sopenharmony_cinames or class or function attributes, type ‘.’.
5977db96d56Sopenharmony_ciFor 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
5987db96d56Sopenharmony_ci<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,
5997db96d56Sopenharmony_cione can specify a drive first.)  Move into subdirectories by typing a
6007db96d56Sopenharmony_cidirectory name and a separator.</p>
6017db96d56Sopenharmony_ci<p>Instead of waiting, or after a box is closed, open a completion box
6027db96d56Sopenharmony_ciimmediately with Show Completions on the Edit menu.  The default hot
6037db96d56Sopenharmony_cikey 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
6047db96d56Sopenharmony_cibefore opening the box, the first match or near miss is made visible.
6057db96d56Sopenharmony_ciThe result is the same as if one enters a prefix
6067db96d56Sopenharmony_ciafter the box is displayed.  Show Completions after a quote completes
6077db96d56Sopenharmony_cifilenames in the current directory instead of a root directory.</p>
6087db96d56Sopenharmony_ci<p>Hitting <kbd class="kbd docutils literal notranslate">Tab</kbd> after a prefix usually has the same effect as Show
6097db96d56Sopenharmony_ciCompletions.  (With no prefix, it indents.)  However, if there is only
6107db96d56Sopenharmony_cione match to the prefix, that match is immediately added to the editor
6117db96d56Sopenharmony_citext without opening a box.</p>
6127db96d56Sopenharmony_ci<p>Invoking ‘Show Completions’, or hitting <kbd class="kbd docutils literal notranslate">Tab</kbd> after a prefix,
6137db96d56Sopenharmony_cioutside of a string and without a preceding ‘.’ opens a box with
6147db96d56Sopenharmony_cikeywords, builtin names, and available module-level names.</p>
6157db96d56Sopenharmony_ci<p>When editing code in an editor (as oppose to Shell), increase the
6167db96d56Sopenharmony_ciavailable module-level names by running your code
6177db96d56Sopenharmony_ciand not restarting the Shell thereafter.  This is especially useful
6187db96d56Sopenharmony_ciafter adding imports at the top of a file.  This also increases
6197db96d56Sopenharmony_cipossible attribute completions.</p>
6207db96d56Sopenharmony_ci<p>Completion boxes initially exclude names beginning with ‘_’ or, for
6217db96d56Sopenharmony_cimodules, not included in ‘__all__’.  The hidden names can be accessed
6227db96d56Sopenharmony_ciby typing ‘_’ after ‘.’, either before or after the box is opened.</p>
6237db96d56Sopenharmony_ci</section>
6247db96d56Sopenharmony_ci<section id="calltips">
6257db96d56Sopenharmony_ci<span id="id4"></span><h3>Calltips<a class="headerlink" href="#calltips" title="Permalink to this heading">¶</a></h3>
6267db96d56Sopenharmony_ci<p>A calltip is shown automatically when one types <kbd class="kbd docutils literal notranslate">(</kbd> after the name
6277db96d56Sopenharmony_ciof an <em>accessible</em> function.  A function name expression may include
6287db96d56Sopenharmony_cidots and subscripts.  A calltip remains until it is clicked, the cursor
6297db96d56Sopenharmony_ciis moved out of the argument area, or <kbd class="kbd docutils literal notranslate">)</kbd> is typed.  Whenever the
6307db96d56Sopenharmony_cicursor is in the argument part of a definition, select Edit and “Show
6317db96d56Sopenharmony_ciCall Tip” on the menu or enter its shortcut to display a calltip.</p>
6327db96d56Sopenharmony_ci<p>The calltip consists of the function’s signature and docstring up to
6337db96d56Sopenharmony_cithe latter’s first blank line or the fifth non-blank line.  (Some builtin
6347db96d56Sopenharmony_cifunctions lack an accessible signature.)  A ‘/’ or ‘*’ in the signature
6357db96d56Sopenharmony_ciindicates that the preceding or following arguments are passed by
6367db96d56Sopenharmony_ciposition or name (keyword) only.  Details are subject to change.</p>
6377db96d56Sopenharmony_ci<p>In Shell, the accessible functions depends on what modules have been
6387db96d56Sopenharmony_ciimported into the user process, including those imported by Idle itself,
6397db96d56Sopenharmony_ciand which definitions have been run, all since the last restart.</p>
6407db96d56Sopenharmony_ci<p>For example, restart the Shell and enter <code class="docutils literal notranslate"><span class="pre">itertools.count(</span></code>.  A calltip
6417db96d56Sopenharmony_ciappears because Idle imports itertools into the user process for its own
6427db96d56Sopenharmony_ciuse.  (This could change.)  Enter <code class="docutils literal notranslate"><span class="pre">turtle.write(</span></code> and nothing appears.
6437db96d56Sopenharmony_ciIdle does not itself import turtle.  The menu entry and shortcut also do
6447db96d56Sopenharmony_cinothing.  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>
6457db96d56Sopenharmony_ciwill display a calltip.</p>
6467db96d56Sopenharmony_ci<p>In an editor, import statements have no effect until one runs the file.
6477db96d56Sopenharmony_ciOne might want to run a file after writing import statements, after
6487db96d56Sopenharmony_ciadding function definitions, or after opening an existing file.</p>
6497db96d56Sopenharmony_ci</section>
6507db96d56Sopenharmony_ci<section id="code-context">
6517db96d56Sopenharmony_ci<span id="id5"></span><h3>Code Context<a class="headerlink" href="#code-context" title="Permalink to this heading">¶</a></h3>
6527db96d56Sopenharmony_ci<p>Within an editor window containing Python code, code context can be toggled
6537db96d56Sopenharmony_ciin order to show or hide a pane at the top of the window.  When shown, this
6547db96d56Sopenharmony_cipane freezes the opening lines for block code, such as those beginning with
6557db96d56Sopenharmony_ci<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
6567db96d56Sopenharmony_ciout of view.  The size of the pane will be expanded and contracted as needed
6577db96d56Sopenharmony_cito show the all current levels of context, up to the maximum number of
6587db96d56Sopenharmony_cilines defined in the Configure IDLE dialog (which defaults to 15).  If there
6597db96d56Sopenharmony_ciare no current context lines and the feature is toggled on, a single blank
6607db96d56Sopenharmony_ciline will display.  Clicking on a line in the context pane will move that
6617db96d56Sopenharmony_ciline to the top of the editor.</p>
6627db96d56Sopenharmony_ci<p>The text and background colors for the context pane can be configured under
6637db96d56Sopenharmony_cithe Highlights tab in the Configure IDLE dialog.</p>
6647db96d56Sopenharmony_ci</section>
6657db96d56Sopenharmony_ci<section id="shell-window">
6667db96d56Sopenharmony_ci<h3>Shell window<a class="headerlink" href="#shell-window" title="Permalink to this heading">¶</a></h3>
6677db96d56Sopenharmony_ci<p>In IDLE’s Shell, enter, edit, and recall complete statements. (Most
6687db96d56Sopenharmony_ciconsoles and terminals only work with a single physical line at a time).</p>
6697db96d56Sopenharmony_ci<p>Submit a single-line statement for execution by hitting <kbd class="kbd docutils literal notranslate">Return</kbd>
6707db96d56Sopenharmony_ciwith the cursor anywhere on the line.  If a line is extended with
6717db96d56Sopenharmony_ciBackslash (<kbd class="kbd docutils literal notranslate">\</kbd>), the cursor must be on the last physical line.
6727db96d56Sopenharmony_ciSubmit a multi-line compound statement by entering a blank line after
6737db96d56Sopenharmony_cithe statement.</p>
6747db96d56Sopenharmony_ci<p>When one pastes code into Shell, it is not compiled and possibly executed
6757db96d56Sopenharmony_ciuntil one hits <kbd class="kbd docutils literal notranslate">Return</kbd>, as specified above.
6767db96d56Sopenharmony_ciOne may edit pasted code first.
6777db96d56Sopenharmony_ciIf one pastes more than one statement into Shell, the result will be a
6787db96d56Sopenharmony_ci<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>
6797db96d56Sopenharmony_ci<p>Lines containing <code class="docutils literal notranslate"><span class="pre">RESTART</span></code> mean that the user execution process has been
6807db96d56Sopenharmony_cire-started.  This occurs when the user execution process has crashed,
6817db96d56Sopenharmony_ciwhen one requests a restart on the Shell menu, or when one runs code
6827db96d56Sopenharmony_ciin an editor window.</p>
6837db96d56Sopenharmony_ci<p>The editing features described in previous subsections work when entering
6847db96d56Sopenharmony_cicode interactively.  IDLE’s Shell window also responds to the following keys.</p>
6857db96d56Sopenharmony_ci<ul>
6867db96d56Sopenharmony_ci<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> interrupts executing command</p></li>
6877db96d56Sopenharmony_ci<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> sends end-of-file; closes window if typed at a <code class="docutils literal notranslate"><span class="pre">&gt;&gt;&gt;</span></code> prompt</p></li>
6887db96d56Sopenharmony_ci<li><p><kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">Alt</kbd>-<kbd class="kbd docutils literal notranslate">/</kbd></kbd> (Expand word) is also useful to reduce typing</p>
6897db96d56Sopenharmony_ci<p>Command history</p>
6907db96d56Sopenharmony_ci<ul class="simple">
6917db96d56Sopenharmony_ci<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> retrieves previous command matching what you have typed. On
6927db96d56Sopenharmony_cimacOS use <kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">p</kbd></kbd>.</p></li>
6937db96d56Sopenharmony_ci<li><p><kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">Alt</kbd>-<kbd class="kbd docutils literal notranslate">n</kbd></kbd> retrieves next. On macOS use <kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">n</kbd></kbd>.</p></li>
6947db96d56Sopenharmony_ci<li><p><kbd class="kbd docutils literal notranslate">Return</kbd> while the cursor is on any previous command
6957db96d56Sopenharmony_ciretrieves that command</p></li>
6967db96d56Sopenharmony_ci</ul>
6977db96d56Sopenharmony_ci</li>
6987db96d56Sopenharmony_ci</ul>
6997db96d56Sopenharmony_ci</section>
7007db96d56Sopenharmony_ci<section id="text-colors">
7017db96d56Sopenharmony_ci<h3>Text colors<a class="headerlink" href="#text-colors" title="Permalink to this heading">¶</a></h3>
7027db96d56Sopenharmony_ci<p>Idle defaults to black on white text, but colors text with special meanings.
7037db96d56Sopenharmony_ciFor the shell, these are shell output, shell error, user output, and
7047db96d56Sopenharmony_ciuser error.  For Python code, at the shell prompt or in an editor, these are
7057db96d56Sopenharmony_cikeywords, builtin class and function names, names following <code class="docutils literal notranslate"><span class="pre">class</span></code> and
7067db96d56Sopenharmony_ci<code class="docutils literal notranslate"><span class="pre">def</span></code>, strings, and comments. For any text window, these are the cursor (when
7077db96d56Sopenharmony_cipresent), found text (when possible), and selected text.</p>
7087db96d56Sopenharmony_ci<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>,
7097db96d56Sopenharmony_ci<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
7107db96d56Sopenharmony_cipattern-matching statements. However, this highlighting is not perfect and
7117db96d56Sopenharmony_ciwill 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>
7127db96d56Sopenharmony_cipatterns.</p>
7137db96d56Sopenharmony_ci<p>Text coloring is done in the background, so uncolorized text is occasionally
7147db96d56Sopenharmony_civisible.  To change the color scheme, use the Configure IDLE dialog
7157db96d56Sopenharmony_ciHighlighting tab.  The marking of debugger breakpoint lines in the editor and
7167db96d56Sopenharmony_citext in popups and dialogs is not user-configurable.</p>
7177db96d56Sopenharmony_ci</section>
7187db96d56Sopenharmony_ci</section>
7197db96d56Sopenharmony_ci<section id="startup-and-code-execution">
7207db96d56Sopenharmony_ci<h2>Startup and Code Execution<a class="headerlink" href="#startup-and-code-execution" title="Permalink to this heading">¶</a></h2>
7217db96d56Sopenharmony_ci<p>Upon startup with the <code class="docutils literal notranslate"><span class="pre">-s</span></code> option, IDLE will execute the file referenced by
7227db96d56Sopenharmony_cithe 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>.
7237db96d56Sopenharmony_ciIDLE 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
7247db96d56Sopenharmony_cireferenced is run.  If <code class="docutils literal notranslate"><span class="pre">IDLESTARTUP</span></code> is not present, IDLE checks for
7257db96d56Sopenharmony_ci<code class="docutils literal notranslate"><span class="pre">PYTHONSTARTUP</span></code>.  Files referenced by these environment variables are
7267db96d56Sopenharmony_ciconvenient places to store functions that are used frequently from the IDLE
7277db96d56Sopenharmony_cishell, or for executing import statements to import common modules.</p>
7287db96d56Sopenharmony_ci<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
7297db96d56Sopenharmony_ciTk file is loaded unconditionally.  This additional file is <code class="docutils literal notranslate"><span class="pre">.Idle.py</span></code> and is
7307db96d56Sopenharmony_cilooked for in the user’s home directory.  Statements in this file will be
7317db96d56Sopenharmony_ciexecuted in the Tk namespace, so this file is not useful for importing
7327db96d56Sopenharmony_cifunctions to be used from IDLE’s Python shell.</p>
7337db96d56Sopenharmony_ci<section id="command-line-usage">
7347db96d56Sopenharmony_ci<h3>Command line usage<a class="headerlink" href="#command-line-usage" title="Permalink to this heading">¶</a></h3>
7357db96d56Sopenharmony_ci<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] ...
7367db96d56Sopenharmony_ci
7377db96d56Sopenharmony_ci-c command  run command in the shell window
7387db96d56Sopenharmony_ci-d          enable debugger and open shell window
7397db96d56Sopenharmony_ci-e          open editor window
7407db96d56Sopenharmony_ci-h          print help message with legal combinations and exit
7417db96d56Sopenharmony_ci-i          open shell window
7427db96d56Sopenharmony_ci-r file     run file in shell window
7437db96d56Sopenharmony_ci-s          run $IDLESTARTUP or $PYTHONSTARTUP first, in shell window
7447db96d56Sopenharmony_ci-t title    set title of shell window
7457db96d56Sopenharmony_ci-           run stdin in shell (- must be last option before args)
7467db96d56Sopenharmony_ci</pre></div>
7477db96d56Sopenharmony_ci</div>
7487db96d56Sopenharmony_ci<p>If there are arguments:</p>
7497db96d56Sopenharmony_ci<ul class="simple">
7507db96d56Sopenharmony_ci<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
7517db96d56Sopenharmony_ci<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>,
7527db96d56Sopenharmony_cior <code class="docutils literal notranslate"><span class="pre">'-r'</span></code>.  No editor window is opened, even if that is the default
7537db96d56Sopenharmony_ciset in the Options dialog.</p></li>
7547db96d56Sopenharmony_ci<li><p>Otherwise, arguments are files opened for editing and
7557db96d56Sopenharmony_ci<code class="docutils literal notranslate"><span class="pre">sys.argv</span></code> reflects the arguments passed to IDLE itself.</p></li>
7567db96d56Sopenharmony_ci</ul>
7577db96d56Sopenharmony_ci</section>
7587db96d56Sopenharmony_ci<section id="startup-failure">
7597db96d56Sopenharmony_ci<h3>Startup failure<a class="headerlink" href="#startup-failure" title="Permalink to this heading">¶</a></h3>
7607db96d56Sopenharmony_ci<p>IDLE uses a socket to communicate between the IDLE GUI process and the user
7617db96d56Sopenharmony_cicode execution process.  A connection must be established whenever the Shell
7627db96d56Sopenharmony_cistarts or restarts.  (The latter is indicated by a divider line that says
7637db96d56Sopenharmony_ci‘RESTART’). If the user process fails to connect to the GUI process, it
7647db96d56Sopenharmony_ciusually displays a <code class="docutils literal notranslate"><span class="pre">Tk</span></code> error box with a ‘cannot connect’ message
7657db96d56Sopenharmony_cithat directs the user here.  It then exits.</p>
7667db96d56Sopenharmony_ci<p>One specific connection failure on Unix systems results from
7677db96d56Sopenharmony_cimisconfigured masquerading rules somewhere in a system’s network setup.
7687db96d56Sopenharmony_ciWhen IDLE is started from a terminal, one will see a message starting
7697db96d56Sopenharmony_ciwith <code class="docutils literal notranslate"><span class="pre">**</span> <span class="pre">Invalid</span> <span class="pre">host:</span></code>.
7707db96d56Sopenharmony_ciThe valid value is <code class="docutils literal notranslate"><span class="pre">127.0.0.1</span> <span class="pre">(idlelib.rpc.LOCALHOST)</span></code>.
7717db96d56Sopenharmony_ciOne 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
7727db96d56Sopenharmony_citerminal window and <code class="docutils literal notranslate"><span class="pre">tcplisten</span> <span class="pre">&lt;same</span> <span class="pre">args&gt;</span></code> in another.</p>
7737db96d56Sopenharmony_ci<p>A common cause of failure is a user-written file with the same name as a
7747db96d56Sopenharmony_cistandard library module, such as <em>random.py</em> and <em>tkinter.py</em>. When such a
7757db96d56Sopenharmony_cifile is located in the same directory as a file that is about to be run,
7767db96d56Sopenharmony_ciIDLE cannot import the stdlib file.  The current fix is to rename the
7777db96d56Sopenharmony_ciuser file.</p>
7787db96d56Sopenharmony_ci<p>Though less common than in the past, an antivirus or firewall program may
7797db96d56Sopenharmony_cistop the connection.  If the program cannot be taught to allow the
7807db96d56Sopenharmony_ciconnection, then it must be turned off for IDLE to work.  It is safe to
7817db96d56Sopenharmony_ciallow this internal connection because no data is visible on external
7827db96d56Sopenharmony_ciports.  A similar problem is a network mis-configuration that blocks
7837db96d56Sopenharmony_ciconnections.</p>
7847db96d56Sopenharmony_ci<p>Python installation issues occasionally stop IDLE: multiple versions can
7857db96d56Sopenharmony_ciclash, or a single installation might need admin access.  If one undo the
7867db96d56Sopenharmony_ciclash, or cannot or does not want to run as admin, it might be easiest to
7877db96d56Sopenharmony_cicompletely remove Python and start over.</p>
7887db96d56Sopenharmony_ci<p>A zombie pythonw.exe process could be a problem.  On Windows, use Task
7897db96d56Sopenharmony_ciManager to check for one and stop it if there is.  Sometimes a restart
7907db96d56Sopenharmony_ciinitiated by a program crash or Keyboard Interrupt (control-C) may fail
7917db96d56Sopenharmony_cito connect.  Dismissing the error box or using Restart Shell on the Shell
7927db96d56Sopenharmony_cimenu may fix a temporary problem.</p>
7937db96d56Sopenharmony_ci<p>When IDLE first starts, it attempts to read user configuration files in
7947db96d56Sopenharmony_ci<code class="docutils literal notranslate"><span class="pre">~/.idlerc/</span></code> (~ is one’s home directory).  If there is a problem, an error
7957db96d56Sopenharmony_cimessage should be displayed.  Leaving aside random disk glitches, this can
7967db96d56Sopenharmony_cibe prevented by never editing the files by hand.  Instead, use the
7977db96d56Sopenharmony_ciconfiguration dialog, under Options.  Once there is an error in a user
7987db96d56Sopenharmony_ciconfiguration file, the best solution may be to delete it and start over
7997db96d56Sopenharmony_ciwith the settings dialog.</p>
8007db96d56Sopenharmony_ci<p>If IDLE quits with no message, and it was not started from a console, try
8017db96d56Sopenharmony_cistarting 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
8027db96d56Sopenharmony_cithis results in an error message.</p>
8037db96d56Sopenharmony_ci<p>On Unix-based systems with tcl/tk older than <code class="docutils literal notranslate"><span class="pre">8.6.11</span></code> (see
8047db96d56Sopenharmony_ci<code class="docutils literal notranslate"><span class="pre">About</span> <span class="pre">IDLE</span></code>) certain characters of certain fonts can cause
8057db96d56Sopenharmony_cia tk failure with a message to the terminal.  This can happen either
8067db96d56Sopenharmony_ciif one starts IDLE to edit a file with such a character or later
8077db96d56Sopenharmony_ciwhen entering such a character.  If one cannot upgrade tcl/tk,
8087db96d56Sopenharmony_cithen re-configure IDLE to use a font that works better.</p>
8097db96d56Sopenharmony_ci</section>
8107db96d56Sopenharmony_ci<section id="running-user-code">
8117db96d56Sopenharmony_ci<h3>Running user code<a class="headerlink" href="#running-user-code" title="Permalink to this heading">¶</a></h3>
8127db96d56Sopenharmony_ci<p>With rare exceptions, the result of executing Python code with IDLE is
8137db96d56Sopenharmony_ciintended to be the same as executing the same code by the default method,
8147db96d56Sopenharmony_cidirectly with Python in a text-mode system console or terminal window.
8157db96d56Sopenharmony_ciHowever, the different interface and operation occasionally affect
8167db96d56Sopenharmony_civisible results.  For instance, <code class="docutils literal notranslate"><span class="pre">sys.modules</span></code> starts with more entries,
8177db96d56Sopenharmony_ciand <code class="docutils literal notranslate"><span class="pre">threading.active_count()</span></code> returns 2 instead of 1.</p>
8187db96d56Sopenharmony_ci<p>By default, IDLE runs user code in a separate OS process rather than in
8197db96d56Sopenharmony_cithe user interface process that runs the shell and editor.  In the execution
8207db96d56Sopenharmony_ciprocess, 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>
8217db96d56Sopenharmony_ciwith objects that get input from and send output to the Shell window.
8227db96d56Sopenharmony_ciThe 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
8237db96d56Sopenharmony_ci<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>
8247db96d56Sopenharmony_ci<p>Sending print output from one process to a text widget in another is
8257db96d56Sopenharmony_cislower than printing to a system terminal in the same process.
8267db96d56Sopenharmony_ciThis has the most effect when printing multiple arguments, as the string
8277db96d56Sopenharmony_cifor each argument, each separator, the newline are sent separately.
8287db96d56Sopenharmony_ciFor development, this is usually not a problem, but if one wants to
8297db96d56Sopenharmony_ciprint faster in IDLE, format and join together everything one wants
8307db96d56Sopenharmony_cidisplayed together and then print a single string.  Both format strings
8317db96d56Sopenharmony_ciand <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>
8327db96d56Sopenharmony_ci<p>IDLE’s standard stream replacements are not inherited by subprocesses
8337db96d56Sopenharmony_cicreated in the execution process, whether directly by user code or by
8347db96d56Sopenharmony_cimodules such as multiprocessing.  If such subprocess use <code class="docutils literal notranslate"><span class="pre">input</span></code> from
8357db96d56Sopenharmony_cisys.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,
8367db96d56Sopenharmony_ciIDLE should be started in a command line window.  (On Windows,
8377db96d56Sopenharmony_ciuse <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>.)
8387db96d56Sopenharmony_ciThe secondary subprocess
8397db96d56Sopenharmony_ciwill then be attached to that window for input and output.</p>
8407db96d56Sopenharmony_ci<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>,
8417db96d56Sopenharmony_ciIDLE’s changes are lost and input from the keyboard and output to the screen
8427db96d56Sopenharmony_ciwill not work correctly.</p>
8437db96d56Sopenharmony_ci<p>When Shell has the focus, it controls the keyboard and screen.  This is
8447db96d56Sopenharmony_cinormally transparent, but functions that directly access the keyboard
8457db96d56Sopenharmony_ciand screen will not work.  These include system-specific functions that
8467db96d56Sopenharmony_cidetermine whether a key has been pressed and if so, which.</p>
8477db96d56Sopenharmony_ci<p>The IDLE code running in the execution process adds frames to the call stack
8487db96d56Sopenharmony_cithat would not be there otherwise.  IDLE wraps <code class="docutils literal notranslate"><span class="pre">sys.getrecursionlimit</span></code> and
8497db96d56Sopenharmony_ci<code class="docutils literal notranslate"><span class="pre">sys.setrecursionlimit</span></code> to reduce the effect of the additional stack
8507db96d56Sopenharmony_ciframes.</p>
8517db96d56Sopenharmony_ci<p>When user code raises SystemExit either directly or by calling sys.exit,
8527db96d56Sopenharmony_ciIDLE returns to a Shell prompt instead of exiting.</p>
8537db96d56Sopenharmony_ci</section>
8547db96d56Sopenharmony_ci<section id="user-output-in-shell">
8557db96d56Sopenharmony_ci<h3>User output in Shell<a class="headerlink" href="#user-output-in-shell" title="Permalink to this heading">¶</a></h3>
8567db96d56Sopenharmony_ci<p>When a program outputs text, the result is determined by the
8577db96d56Sopenharmony_cicorresponding output device.  When IDLE executes user code, <code class="docutils literal notranslate"><span class="pre">sys.stdout</span></code>
8587db96d56Sopenharmony_ciand <code class="docutils literal notranslate"><span class="pre">sys.stderr</span></code> are connected to the display area of IDLE’s Shell.  Some of
8597db96d56Sopenharmony_ciits features are inherited from the underlying Tk Text widget.  Others
8607db96d56Sopenharmony_ciare programmed additions.  Where it matters, Shell is designed for development
8617db96d56Sopenharmony_cirather than production runs.</p>
8627db96d56Sopenharmony_ci<p>For instance, Shell never throws away output.  A program that sends unlimited
8637db96d56Sopenharmony_cioutput to Shell will eventually fill memory, resulting in a memory error.
8647db96d56Sopenharmony_ciIn contrast, some system text windows only keep the last n lines of output.
8657db96d56Sopenharmony_ciA Windows console, for instance, keeps a user-settable 1 to 9999 lines,
8667db96d56Sopenharmony_ciwith 300 the default.</p>
8677db96d56Sopenharmony_ci<p>A Tk Text widget, and hence IDLE’s Shell, displays characters (codepoints) in
8687db96d56Sopenharmony_cithe BMP (Basic Multilingual Plane) subset of Unicode.  Which characters are
8697db96d56Sopenharmony_cidisplayed with a proper glyph and which with a replacement box depends on the
8707db96d56Sopenharmony_cioperating system and installed fonts.  Tab characters cause the following text
8717db96d56Sopenharmony_cito begin after the next tab stop. (They occur every 8 ‘characters’).  Newline
8727db96d56Sopenharmony_cicharacters cause following text to appear on a new line.  Other control
8737db96d56Sopenharmony_cicharacters are ignored or displayed as a space, box, or something else,
8747db96d56Sopenharmony_cidepending on the operating system and font.  (Moving the text cursor through
8757db96d56Sopenharmony_cisuch output with arrow keys may exhibit some surprising spacing behavior.)</p>
8767db96d56Sopenharmony_ci<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">s</span> <span class="o">=</span> <span class="s1">&#39;a</span><span class="se">\t</span><span class="s1">b</span><span class="se">\a</span><span class="s1">&lt;</span><span class="se">\x02</span><span class="s1">&gt;&lt;</span><span class="se">\r</span><span class="s1">&gt;</span><span class="se">\b</span><span class="s1">c</span><span class="se">\n</span><span class="s1">d&#39;</span>  <span class="c1"># Enter 22 chars.</span>
8777db96d56Sopenharmony_ci<span class="gp">&gt;&gt;&gt; </span><span class="nb">len</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
8787db96d56Sopenharmony_ci<span class="go">14</span>
8797db96d56Sopenharmony_ci<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span>  <span class="c1"># Display repr(s)</span>
8807db96d56Sopenharmony_ci<span class="go">&#39;a\tb\x07&lt;\x02&gt;&lt;\r&gt;\x08c\nd&#39;</span>
8817db96d56Sopenharmony_ci<span class="gp">&gt;&gt;&gt; </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">&#39;&#39;</span><span class="p">)</span>  <span class="c1"># Display s as is.</span>
8827db96d56Sopenharmony_ci<span class="go"># Result varies by OS and font.  Try it.</span>
8837db96d56Sopenharmony_ci</pre></div>
8847db96d56Sopenharmony_ci</div>
8857db96d56Sopenharmony_ci<p>The <code class="docutils literal notranslate"><span class="pre">repr</span></code> function is used for interactive echo of expression
8867db96d56Sopenharmony_civalues.  It returns an altered version of the input string in which
8877db96d56Sopenharmony_cicontrol codes, some BMP codepoints, and all non-BMP codepoints are
8887db96d56Sopenharmony_cireplaced with escape codes. As demonstrated above, it allows one to
8897db96d56Sopenharmony_ciidentify the characters in a string, regardless of how they are displayed.</p>
8907db96d56Sopenharmony_ci<p>Normal and error output are generally kept separate (on separate lines)
8917db96d56Sopenharmony_cifrom code input and each other.  They each get different highlight colors.</p>
8927db96d56Sopenharmony_ci<p>For SyntaxError tracebacks, the normal ‘^’ marking where the error was
8937db96d56Sopenharmony_cidetected is replaced by coloring the text with an error highlight.
8947db96d56Sopenharmony_ciWhen code run from a file causes other exceptions, one may right click
8957db96d56Sopenharmony_cion a traceback line to jump to the corresponding line in an IDLE editor.
8967db96d56Sopenharmony_ciThe file will be opened if necessary.</p>
8977db96d56Sopenharmony_ci<p>Shell has a special facility for squeezing output lines down to a
8987db96d56Sopenharmony_ci‘Squeezed text’ label.  This is done automatically
8997db96d56Sopenharmony_cifor output over N lines (N = 50 by default).
9007db96d56Sopenharmony_ciN can be changed in the PyShell section of the General
9017db96d56Sopenharmony_cipage of the Settings dialog.  Output with fewer lines can be squeezed by
9027db96d56Sopenharmony_ciright clicking on the output.  This can be useful lines long enough to slow
9037db96d56Sopenharmony_cidown scrolling.</p>
9047db96d56Sopenharmony_ci<p>Squeezed output is expanded in place by double-clicking the label.
9057db96d56Sopenharmony_ciIt can also be sent to the clipboard or a separate view window by
9067db96d56Sopenharmony_ciright-clicking the label.</p>
9077db96d56Sopenharmony_ci</section>
9087db96d56Sopenharmony_ci<section id="developing-tkinter-applications">
9097db96d56Sopenharmony_ci<h3>Developing tkinter applications<a class="headerlink" href="#developing-tkinter-applications" title="Permalink to this heading">¶</a></h3>
9107db96d56Sopenharmony_ci<p>IDLE is intentionally different from standard Python in order to
9117db96d56Sopenharmony_cifacilitate 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>
9127db96d56Sopenharmony_ci<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
9137db96d56Sopenharmony_ciin IDLE and a tk window appears.  In standard Python, one must also enter
9147db96d56Sopenharmony_ci<code class="docutils literal notranslate"><span class="pre">root.update()</span></code> to see the window.  IDLE does the equivalent in the
9157db96d56Sopenharmony_cibackground, about 20 times a second, which is about every 50 milliseconds.
9167db96d56Sopenharmony_ciNext 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,
9177db96d56Sopenharmony_cinothing visibly changes in standard Python until one enters <code class="docutils literal notranslate"><span class="pre">root.update()</span></code>.</p>
9187db96d56Sopenharmony_ci<p>Most tkinter programs run <code class="docutils literal notranslate"><span class="pre">root.mainloop()</span></code>, which usually does not
9197db96d56Sopenharmony_cireturn until the tk app is destroyed.  If the program is run with
9207db96d56Sopenharmony_ci<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">&gt;&gt;&gt;</span></code> shell prompt does not
9217db96d56Sopenharmony_ciappear until <code class="docutils literal notranslate"><span class="pre">mainloop()</span></code> returns, at which time there is nothing left
9227db96d56Sopenharmony_cito interact with.</p>
9237db96d56Sopenharmony_ci<p>When running a tkinter program from an IDLE editor, one can comment out
9247db96d56Sopenharmony_cithe mainloop call.  One then gets a shell prompt immediately and can
9257db96d56Sopenharmony_ciinteract with the live application.  One just has to remember to
9267db96d56Sopenharmony_cire-enable the mainloop call when running in standard Python.</p>
9277db96d56Sopenharmony_ci</section>
9287db96d56Sopenharmony_ci<section id="running-without-a-subprocess">
9297db96d56Sopenharmony_ci<h3>Running without a subprocess<a class="headerlink" href="#running-without-a-subprocess" title="Permalink to this heading">¶</a></h3>
9307db96d56Sopenharmony_ci<p>By default, IDLE executes user code in a separate subprocess via a socket,
9317db96d56Sopenharmony_ciwhich uses the internal loopback interface.  This connection is not
9327db96d56Sopenharmony_ciexternally visible and no data is sent to or received from the internet.
9337db96d56Sopenharmony_ciIf firewall software complains anyway, you can ignore it.</p>
9347db96d56Sopenharmony_ci<p>If the attempt to make the socket connection fails, Idle will notify you.
9357db96d56Sopenharmony_ciSuch failures are sometimes transient, but if persistent, the problem
9367db96d56Sopenharmony_cimay be either a firewall blocking the connection or misconfiguration of
9377db96d56Sopenharmony_cia particular system.  Until the problem is fixed, one can run Idle with
9387db96d56Sopenharmony_cithe -n command line switch.</p>
9397db96d56Sopenharmony_ci<p>If IDLE is started with the -n command line switch it will run in a
9407db96d56Sopenharmony_cisingle process and will not create the subprocess which runs the RPC
9417db96d56Sopenharmony_ciPython execution server.  This can be useful if Python cannot create
9427db96d56Sopenharmony_cithe subprocess or the RPC socket interface on your platform.  However,
9437db96d56Sopenharmony_ciin this mode user code is not isolated from IDLE itself.  Also, the
9447db96d56Sopenharmony_cienvironment is not restarted when Run/Run Module (F5) is selected.  If
9457db96d56Sopenharmony_ciyour code has been modified, you must reload() the affected modules and
9467db96d56Sopenharmony_cire-import any specific items (e.g. from foo import baz) if the changes
9477db96d56Sopenharmony_ciare to take effect.  For these reasons, it is preferable to run IDLE
9487db96d56Sopenharmony_ciwith the default subprocess if at all possible.</p>
9497db96d56Sopenharmony_ci<div class="deprecated">
9507db96d56Sopenharmony_ci<p><span class="versionmodified deprecated">Deprecated since version 3.4.</span></p>
9517db96d56Sopenharmony_ci</div>
9527db96d56Sopenharmony_ci</section>
9537db96d56Sopenharmony_ci</section>
9547db96d56Sopenharmony_ci<section id="help-and-preferences">
9557db96d56Sopenharmony_ci<h2>Help and Preferences<a class="headerlink" href="#help-and-preferences" title="Permalink to this heading">¶</a></h2>
9567db96d56Sopenharmony_ci<section id="help-sources">
9577db96d56Sopenharmony_ci<span id="id6"></span><h3>Help sources<a class="headerlink" href="#help-sources" title="Permalink to this heading">¶</a></h3>
9587db96d56Sopenharmony_ci<p>Help menu entry “IDLE Help” displays a formatted html version of the
9597db96d56Sopenharmony_ciIDLE chapter of the Library Reference.  The result, in a read-only
9607db96d56Sopenharmony_citkinter text window, is close to what one sees in a web browser.
9617db96d56Sopenharmony_ciNavigate through the text with a mousewheel,
9627db96d56Sopenharmony_cithe scrollbar, or up and down arrow keys held down.
9637db96d56Sopenharmony_ciOr click the TOC (Table of Contents) button and select a section
9647db96d56Sopenharmony_ciheader in the opened box.</p>
9657db96d56Sopenharmony_ci<p>Help menu entry “Python Docs” opens the extensive sources of help,
9667db96d56Sopenharmony_ciincluding tutorials, available at <code class="docutils literal notranslate"><span class="pre">docs.python.org/x.y</span></code>, where ‘x.y9677db96d56Sopenharmony_ciis the currently running Python version.  If your system
9687db96d56Sopenharmony_cihas an off-line copy of the docs (this may be an installation option),
9697db96d56Sopenharmony_cithat will be opened instead.</p>
9707db96d56Sopenharmony_ci<p>Selected URLs can be added or removed from the help menu at any time using the
9717db96d56Sopenharmony_ciGeneral tab of the Configure IDLE dialog.</p>
9727db96d56Sopenharmony_ci</section>
9737db96d56Sopenharmony_ci<section id="setting-preferences">
9747db96d56Sopenharmony_ci<span id="preferences"></span><h3>Setting preferences<a class="headerlink" href="#setting-preferences" title="Permalink to this heading">¶</a></h3>
9757db96d56Sopenharmony_ci<p>The font preferences, highlighting, keys, and general preferences can be
9767db96d56Sopenharmony_cichanged via Configure IDLE on the Option menu.
9777db96d56Sopenharmony_ciNon-default user settings are saved in a <code class="docutils literal notranslate"><span class="pre">.idlerc</span></code> directory in the user’s
9787db96d56Sopenharmony_cihome directory.  Problems caused by bad user configuration files are solved
9797db96d56Sopenharmony_ciby editing or deleting one or more of the files in <code class="docutils literal notranslate"><span class="pre">.idlerc</span></code>.</p>
9807db96d56Sopenharmony_ci<p>On the Font tab, see the text sample for the effect of font face and size
9817db96d56Sopenharmony_cion multiple characters in multiple languages.  Edit the sample to add
9827db96d56Sopenharmony_ciother characters of personal interest.  Use the sample to select
9837db96d56Sopenharmony_cimonospaced fonts.  If particular characters have problems in Shell or an
9847db96d56Sopenharmony_cieditor, add them to the top of the sample and try changing first size
9857db96d56Sopenharmony_ciand then font.</p>
9867db96d56Sopenharmony_ci<p>On the Highlights and Keys tab, select a built-in or custom color theme
9877db96d56Sopenharmony_ciand key set.  To use a newer built-in color theme or key set with older
9887db96d56Sopenharmony_ciIDLEs, save it as a new custom theme or key set and it well be accessible
9897db96d56Sopenharmony_cito older IDLEs.</p>
9907db96d56Sopenharmony_ci</section>
9917db96d56Sopenharmony_ci<section id="idle-on-macos">
9927db96d56Sopenharmony_ci<h3>IDLE on macOS<a class="headerlink" href="#idle-on-macos" title="Permalink to this heading">¶</a></h3>
9937db96d56Sopenharmony_ci<p>Under System Preferences: Dock, one can set “Prefer tabs when opening
9947db96d56Sopenharmony_cidocuments” to “Always”.  This setting is not compatible with the tk/tkinter
9957db96d56Sopenharmony_ciGUI framework used by IDLE, and it breaks a few IDLE features.</p>
9967db96d56Sopenharmony_ci</section>
9977db96d56Sopenharmony_ci<section id="extensions">
9987db96d56Sopenharmony_ci<h3>Extensions<a class="headerlink" href="#extensions" title="Permalink to this heading">¶</a></h3>
9997db96d56Sopenharmony_ci<p>IDLE contains an extension facility.  Preferences for extensions can be
10007db96d56Sopenharmony_cichanged with the Extensions tab of the preferences dialog. See the
10017db96d56Sopenharmony_cibeginning of config-extensions.def in the idlelib directory for further
10027db96d56Sopenharmony_ciinformation.  The only current default extension is zzdummy, an example
10037db96d56Sopenharmony_cialso used for testing.</p>
10047db96d56Sopenharmony_ci</section>
10057db96d56Sopenharmony_ci</section>
10067db96d56Sopenharmony_ci<section id="module-idlelib">
10077db96d56Sopenharmony_ci<span id="idlelib"></span><h2>idlelib<a class="headerlink" href="#module-idlelib" title="Permalink to this heading">¶</a></h2>
10087db96d56Sopenharmony_ci<p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/main/Lib/idlelib">Lib/idlelib</a></p>
10097db96d56Sopenharmony_ci<hr class="docutils" />
10107db96d56Sopenharmony_ci<p>The Lib/idlelib package implements the IDLE application.  See the rest
10117db96d56Sopenharmony_ciof this page for how to use IDLE.</p>
10127db96d56Sopenharmony_ci<p>The files in idlelib are described in idlelib/README.txt.  Access it
10137db96d56Sopenharmony_cieither in idlelib or click Help =&gt; About IDLE on the IDLE menu.  This
10147db96d56Sopenharmony_cifile also maps IDLE menu items to the code that implements the item.
10157db96d56Sopenharmony_ciExcept for files listed under ‘Startup’, the idlelib code is ‘private’ in
10167db96d56Sopenharmony_cisense 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>
10177db96d56Sopenharmony_ci</section>
10187db96d56Sopenharmony_ci</section>
10197db96d56Sopenharmony_ci
10207db96d56Sopenharmony_ci
10217db96d56Sopenharmony_ci            <div class="clearer"></div>
10227db96d56Sopenharmony_ci          </div>
10237db96d56Sopenharmony_ci        </div>
10247db96d56Sopenharmony_ci      </div>
10257db96d56Sopenharmony_ci      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
10267db96d56Sopenharmony_ci        <div class="sphinxsidebarwrapper">
10277db96d56Sopenharmony_ci  <div>
10287db96d56Sopenharmony_ci    <h3><a href="../contents.html">Table of Contents</a></h3>
10297db96d56Sopenharmony_ci    <ul>
10307db96d56Sopenharmony_ci<li><a class="reference internal" href="#">IDLE</a><ul>
10317db96d56Sopenharmony_ci<li><a class="reference internal" href="#menus">Menus</a><ul>
10327db96d56Sopenharmony_ci<li><a class="reference internal" href="#file-menu-shell-and-editor">File menu (Shell and Editor)</a></li>
10337db96d56Sopenharmony_ci<li><a class="reference internal" href="#edit-menu-shell-and-editor">Edit menu (Shell and Editor)</a></li>
10347db96d56Sopenharmony_ci<li><a class="reference internal" href="#format-menu-editor-window-only">Format menu (Editor window only)</a></li>
10357db96d56Sopenharmony_ci<li><a class="reference internal" href="#run-menu-editor-window-only">Run menu (Editor window only)</a></li>
10367db96d56Sopenharmony_ci<li><a class="reference internal" href="#shell-menu-shell-window-only">Shell menu (Shell window only)</a></li>
10377db96d56Sopenharmony_ci<li><a class="reference internal" href="#debug-menu-shell-window-only">Debug menu (Shell window only)</a></li>
10387db96d56Sopenharmony_ci<li><a class="reference internal" href="#options-menu-shell-and-editor">Options menu (Shell and Editor)</a></li>
10397db96d56Sopenharmony_ci<li><a class="reference internal" href="#window-menu-shell-and-editor">Window menu (Shell and Editor)</a></li>
10407db96d56Sopenharmony_ci<li><a class="reference internal" href="#help-menu-shell-and-editor">Help menu (Shell and Editor)</a></li>
10417db96d56Sopenharmony_ci<li><a class="reference internal" href="#context-menus">Context menus</a></li>
10427db96d56Sopenharmony_ci</ul>
10437db96d56Sopenharmony_ci</li>
10447db96d56Sopenharmony_ci<li><a class="reference internal" href="#editing-and-navigation">Editing and Navigation</a><ul>
10457db96d56Sopenharmony_ci<li><a class="reference internal" href="#editor-windows">Editor windows</a></li>
10467db96d56Sopenharmony_ci<li><a class="reference internal" href="#key-bindings">Key bindings</a></li>
10477db96d56Sopenharmony_ci<li><a class="reference internal" href="#automatic-indentation">Automatic indentation</a></li>
10487db96d56Sopenharmony_ci<li><a class="reference internal" href="#search-and-replace">Search and Replace</a></li>
10497db96d56Sopenharmony_ci<li><a class="reference internal" href="#completions">Completions</a></li>
10507db96d56Sopenharmony_ci<li><a class="reference internal" href="#calltips">Calltips</a></li>
10517db96d56Sopenharmony_ci<li><a class="reference internal" href="#code-context">Code Context</a></li>
10527db96d56Sopenharmony_ci<li><a class="reference internal" href="#shell-window">Shell window</a></li>
10537db96d56Sopenharmony_ci<li><a class="reference internal" href="#text-colors">Text colors</a></li>
10547db96d56Sopenharmony_ci</ul>
10557db96d56Sopenharmony_ci</li>
10567db96d56Sopenharmony_ci<li><a class="reference internal" href="#startup-and-code-execution">Startup and Code Execution</a><ul>
10577db96d56Sopenharmony_ci<li><a class="reference internal" href="#command-line-usage">Command line usage</a></li>
10587db96d56Sopenharmony_ci<li><a class="reference internal" href="#startup-failure">Startup failure</a></li>
10597db96d56Sopenharmony_ci<li><a class="reference internal" href="#running-user-code">Running user code</a></li>
10607db96d56Sopenharmony_ci<li><a class="reference internal" href="#user-output-in-shell">User output in Shell</a></li>
10617db96d56Sopenharmony_ci<li><a class="reference internal" href="#developing-tkinter-applications">Developing tkinter applications</a></li>
10627db96d56Sopenharmony_ci<li><a class="reference internal" href="#running-without-a-subprocess">Running without a subprocess</a></li>
10637db96d56Sopenharmony_ci</ul>
10647db96d56Sopenharmony_ci</li>
10657db96d56Sopenharmony_ci<li><a class="reference internal" href="#help-and-preferences">Help and Preferences</a><ul>
10667db96d56Sopenharmony_ci<li><a class="reference internal" href="#help-sources">Help sources</a></li>
10677db96d56Sopenharmony_ci<li><a class="reference internal" href="#setting-preferences">Setting preferences</a></li>
10687db96d56Sopenharmony_ci<li><a class="reference internal" href="#idle-on-macos">IDLE on macOS</a></li>
10697db96d56Sopenharmony_ci<li><a class="reference internal" href="#extensions">Extensions</a></li>
10707db96d56Sopenharmony_ci</ul>
10717db96d56Sopenharmony_ci</li>
10727db96d56Sopenharmony_ci<li><a class="reference internal" href="#module-idlelib">idlelib</a></li>
10737db96d56Sopenharmony_ci</ul>
10747db96d56Sopenharmony_ci</li>
10757db96d56Sopenharmony_ci</ul>
10767db96d56Sopenharmony_ci
10777db96d56Sopenharmony_ci  </div>
10787db96d56Sopenharmony_ci  <div>
10797db96d56Sopenharmony_ci    <h4>Previous topic</h4>
10807db96d56Sopenharmony_ci    <p class="topless"><a href="tkinter.tix.html"
10817db96d56Sopenharmony_ci                          title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.tix</span></code> — Extension widgets for Tk</a></p>
10827db96d56Sopenharmony_ci  </div>
10837db96d56Sopenharmony_ci  <div>
10847db96d56Sopenharmony_ci    <h4>Next topic</h4>
10857db96d56Sopenharmony_ci    <p class="topless"><a href="development.html"
10867db96d56Sopenharmony_ci                          title="next chapter">Development Tools</a></p>
10877db96d56Sopenharmony_ci  </div>
10887db96d56Sopenharmony_ci  <div role="note" aria-label="source link">
10897db96d56Sopenharmony_ci    <h3>This Page</h3>
10907db96d56Sopenharmony_ci    <ul class="this-page-menu">
10917db96d56Sopenharmony_ci      <li><a href="../bugs.html">Report a Bug</a></li>
10927db96d56Sopenharmony_ci      <li>
10937db96d56Sopenharmony_ci        <a href="https://github.com/python/cpython/blob/main/Doc/library/idle.rst"
10947db96d56Sopenharmony_ci            rel="nofollow">Show Source
10957db96d56Sopenharmony_ci        </a>
10967db96d56Sopenharmony_ci      </li>
10977db96d56Sopenharmony_ci    </ul>
10987db96d56Sopenharmony_ci  </div>
10997db96d56Sopenharmony_ci        </div>
11007db96d56Sopenharmony_ci<div id="sidebarbutton" title="Collapse sidebar">
11017db96d56Sopenharmony_ci<span>«</span>
11027db96d56Sopenharmony_ci</div>
11037db96d56Sopenharmony_ci
11047db96d56Sopenharmony_ci      </div>
11057db96d56Sopenharmony_ci      <div class="clearer"></div>
11067db96d56Sopenharmony_ci    </div>
11077db96d56Sopenharmony_ci    <div class="related" role="navigation" aria-label="related navigation">
11087db96d56Sopenharmony_ci      <h3>Navigation</h3>
11097db96d56Sopenharmony_ci      <ul>
11107db96d56Sopenharmony_ci        <li class="right" style="margin-right: 10px">
11117db96d56Sopenharmony_ci          <a href="../genindex.html" title="General Index"
11127db96d56Sopenharmony_ci             >index</a></li>
11137db96d56Sopenharmony_ci        <li class="right" >
11147db96d56Sopenharmony_ci          <a href="../py-modindex.html" title="Python Module Index"
11157db96d56Sopenharmony_ci             >modules</a> |</li>
11167db96d56Sopenharmony_ci        <li class="right" >
11177db96d56Sopenharmony_ci          <a href="development.html" title="Development Tools"
11187db96d56Sopenharmony_ci             >next</a> |</li>
11197db96d56Sopenharmony_ci        <li class="right" >
11207db96d56Sopenharmony_ci          <a href="tkinter.tix.html" title="tkinter.tix — Extension widgets for Tk"
11217db96d56Sopenharmony_ci             >previous</a> |</li>
11227db96d56Sopenharmony_ci
11237db96d56Sopenharmony_ci          <li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
11247db96d56Sopenharmony_ci          <li><a href="https://www.python.org/">Python</a> &#187;</li>
11257db96d56Sopenharmony_ci          <li class="switchers">
11267db96d56Sopenharmony_ci            <div class="language_switcher_placeholder"></div>
11277db96d56Sopenharmony_ci            <div class="version_switcher_placeholder"></div>
11287db96d56Sopenharmony_ci          </li>
11297db96d56Sopenharmony_ci          <li>
11307db96d56Sopenharmony_ci
11317db96d56Sopenharmony_ci          </li>
11327db96d56Sopenharmony_ci    <li id="cpython-language-and-version">
11337db96d56Sopenharmony_ci      <a href="../index.html">3.12.0a0 Documentation</a> &#187;
11347db96d56Sopenharmony_ci    </li>
11357db96d56Sopenharmony_ci
11367db96d56Sopenharmony_ci          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
11377db96d56Sopenharmony_ci          <li class="nav-item nav-item-2"><a href="tk.html" >Graphical User Interfaces with Tk</a> &#187;</li>
11387db96d56Sopenharmony_ci        <li class="nav-item nav-item-this"><a href="">IDLE</a></li>
11397db96d56Sopenharmony_ci                <li class="right">
11407db96d56Sopenharmony_ci
11417db96d56Sopenharmony_ci
11427db96d56Sopenharmony_ci    <div class="inline-search" role="search">
11437db96d56Sopenharmony_ci        <form class="inline-search" action="../search.html" method="get">
11447db96d56Sopenharmony_ci          <input placeholder="Quick search" aria-label="Quick search" type="text" name="q" />
11457db96d56Sopenharmony_ci          <input type="submit" value="Go" />
11467db96d56Sopenharmony_ci          <input type="hidden" name="check_keywords" value="yes" />
11477db96d56Sopenharmony_ci          <input type="hidden" name="area" value="default" />
11487db96d56Sopenharmony_ci        </form>
11497db96d56Sopenharmony_ci    </div>
11507db96d56Sopenharmony_ci                     |
11517db96d56Sopenharmony_ci                </li>
11527db96d56Sopenharmony_ci
11537db96d56Sopenharmony_ci      </ul>
11547db96d56Sopenharmony_ci    </div>
11557db96d56Sopenharmony_ci    <div class="footer">
11567db96d56Sopenharmony_ci    &copy; <a href="../copyright.html">Copyright</a> 2001-2022, Python Software Foundation.
11577db96d56Sopenharmony_ci    <br />
11587db96d56Sopenharmony_ci    This page is licensed under the Python Software Foundation License Version 2.
11597db96d56Sopenharmony_ci    <br />
11607db96d56Sopenharmony_ci    Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
11617db96d56Sopenharmony_ci    <br />
11627db96d56Sopenharmony_ci    See <a href="/license.html">History and License</a> for more information.<br />
11637db96d56Sopenharmony_ci    <br />
11647db96d56Sopenharmony_ci
11657db96d56Sopenharmony_ci    The Python Software Foundation is a non-profit corporation.
11667db96d56Sopenharmony_ci<a href="https://www.python.org/psf/donations/">Please donate.</a>
11677db96d56Sopenharmony_ci<br />
11687db96d56Sopenharmony_ci    <br />
11697db96d56Sopenharmony_ci
11707db96d56Sopenharmony_ci    Last updated on Sep 03, 2022.
11717db96d56Sopenharmony_ci    <a href="/bugs.html">Found a bug</a>?
11727db96d56Sopenharmony_ci    <br />
11737db96d56Sopenharmony_ci
11747db96d56Sopenharmony_ci    Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 5.0.2.
11757db96d56Sopenharmony_ci    </div>
11767db96d56Sopenharmony_ci
11777db96d56Sopenharmony_ci  </body>
11787db96d56Sopenharmony_ci</html>
1179