Home | History | Annotate | Download | only in idlelib
      1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      2   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      3 
      4 
      5 <html xmlns="http://www.w3.org/1999/xhtml">
      6   <head>
      7     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      8 
      9     <title>25.5. IDLE &mdash; Python 3.5.2 documentation</title>
     10 
     11     <link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
     12     <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
     13 
     14     <script type="text/javascript">
     15       var DOCUMENTATION_OPTIONS = {
     16         URL_ROOT:    '../',
     17         VERSION:     '3.5.2',
     18         COLLAPSE_INDEX: false,
     19         FILE_SUFFIX: '.html',
     20         HAS_SOURCE:  true
     21       };
     22     </script>
     23     <script type="text/javascript" src="../_static/jquery.js"></script>
     24     <script type="text/javascript" src="../_static/underscore.js"></script>
     25     <script type="text/javascript" src="../_static/doctools.js"></script>
     26     <script type="text/javascript" src="../_static/sidebar.js"></script>
     27     <link rel="search" type="application/opensearchdescription+xml"
     28           title="Search within Python 3.5.2 documentation"
     29           href="../_static/opensearch.xml"/>
     30     <link rel="author" title="About these documents" href="../about.html" />
     31     <link rel="copyright" title="Copyright" href="../copyright.html" />
     32     <link rel="top" title="Python 3.5.2 documentation" href="../contents.html" />
     33     <link rel="up" title="25. Graphical User Interfaces with Tk" href="tk.html" />
     34     <link rel="next" title="25.6. Other Graphical User Interface Packages" href="othergui.html" />
     35     <link rel="prev" title="25.4. tkinter.scrolledtext  Scrolled Text Widget" href="tkinter.scrolledtext.html" />
     36     <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
     37     <script type="text/javascript" src="../_static/copybutton.js"></script>
     38 
     39 
     40 
     41 
     42   </head>
     43   <body role="document">
     44     <div class="related" role="navigation" aria-label="related navigation">
     45       <h3>Navigation</h3>
     46       <ul>
     47         <li class="right" style="margin-right: 10px">
     48           <a href="../genindex.html" title="General Index"
     49              accesskey="I">index</a></li>
     50         <li class="right" >
     51           <a href="../py-modindex.html" title="Python Module Index"
     52              >modules</a> |</li>
     53         <li class="right" >
     54           <a href="othergui.html" title="25.6. Other Graphical User Interface Packages"
     55              accesskey="N">next</a> |</li>
     56         <li class="right" >
     57           <a href="tkinter.scrolledtext.html" title="25.4. tkinter.scrolledtext  Scrolled Text Widget"
     58              accesskey="P">previous</a> |</li>
     59         <li><img src="../_static/py.png" alt=""
     60                  style="vertical-align: middle; margin-top: -1px"/></li>
     61         <li><a href="https://www.python.org/">Python</a> &raquo;</li>
     62         <li>
     63           <a href="../index.html">3.5.2 Documentation</a> &raquo;
     64         </li>
     65 
     66           <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &raquo;</li>
     67           <li class="nav-item nav-item-2"><a href="tk.html" accesskey="U">25. Graphical User Interfaces with Tk</a> &raquo;</li>
     68     <li class="right">
     69 
     70 
     71     <div class="inline-search" style="display: none" role="search">
     72         <form class="inline-search" action="../search.html" method="get">
     73           <input placeholder="Quick search" type="text" name="q" />
     74           <input type="submit" value="Go" />
     75           <input type="hidden" name="check_keywords" value="yes" />
     76           <input type="hidden" name="area" value="default" />
     77         </form>
     78     </div>
     79     <script type="text/javascript">$('.inline-search').show(0);</script>
     80          |
     81     </li>
     82 
     83       </ul>
     84     </div>
     85 
     86     <div class="document">
     87       <div class="documentwrapper">
     88         <div class="bodywrapper">
     89           <div class="body" role="main">
     90 
     91   <div class="section" id="idle">
     92 <span id="id1"></span><h1>25.5. IDLE<a class="headerlink" href="#idle" title="Permalink to this headline"></a></h1>
     93 <p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.5/Lib/idlelib">Lib/idlelib/</a></p>
     94 <hr class="docutils" id="index-0" />
     95 <p>IDLE is Python&#8217;s Integrated Development and Learning Environment.</p>
     96 <p>IDLE has the following features:</p>
     97 <ul class="simple">
     98 <li>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"><span class="pre">tkinter</span></code></a> GUI toolkit</li>
     99 <li>cross-platform: works mostly the same on Windows, Unix, and Mac OS X</li>
    100 <li>Python shell window (interactive interpreter) with colorizing
    101 of code input, output, and error messages</li>
    102 <li>multi-window text editor with multiple undo, Python colorizing,
    103 smart indent, call tips, auto completion, and other features</li>
    104 <li>search within any window, replace within editor windows, and search
    105 through multiple files (grep)</li>
    106 <li>debugger with persistent breakpoints, stepping, and viewing
    107 of global and local namespaces</li>
    108 <li>configuration, browsers, and other dialogs</li>
    109 </ul>
    110 <div class="section" id="menus">
    111 <h2>25.5.1. Menus<a class="headerlink" href="#menus" title="Permalink to this headline"></a></h2>
    112 <p>IDLE has two main window types, the Shell window and the Editor window.  It is
    113 possible to have multiple editor windows simultaneously.  Output windows, such
    114 as used for Edit / Find in Files, are a subtype of edit window.  They currently
    115 have the same top menu as Editor windows but a different default title and
    116 context menu.</p>
    117 <p>IDLE&#8217;s menus dynamically change based on which window is currently selected.
    118 Each menu documented below indicates which window type it is associated with.</p>
    119 <div class="section" id="file-menu-shell-and-editor">
    120 <h3>25.5.1.1. File menu (Shell and Editor)<a class="headerlink" href="#file-menu-shell-and-editor" title="Permalink to this headline"></a></h3>
    121 <dl class="docutils">
    122 <dt>New File</dt>
    123 <dd>Create a new file editing window.</dd>
    124 <dt>Open...</dt>
    125 <dd>Open an existing file with an Open dialog.</dd>
    126 <dt>Recent Files</dt>
    127 <dd>Open a list of recent files.  Click one to open it.</dd>
    128 <dt>Open Module...</dt>
    129 <dd>Open an existing module (searches sys.path).</dd>
    130 </dl>
    131 <dl class="docutils" id="index-1">
    132 <dt>Class Browser</dt>
    133 <dd>Show functions, classes, and methods in the current Editor file in a
    134 tree structure.  In the shell, open a module first.</dd>
    135 <dt>Path Browser</dt>
    136 <dd>Show sys.path directories, modules, functions, classes and methods in a
    137 tree structure.</dd>
    138 <dt>Save</dt>
    139 <dd>Save the current window to the associated file, if there is one.  Windows
    140 that have been changed since being opened or last saved have a * before
    141 and after the window title.  If there is no associated file,
    142 do Save As instead.</dd>
    143 <dt>Save As...</dt>
    144 <dd>Save the current window with a Save As dialog.  The file saved becomes the
    145 new associated file for the window.</dd>
    146 <dt>Save Copy As...</dt>
    147 <dd>Save the current window to different file without changing the associated
    148 file.</dd>
    149 <dt>Print Window</dt>
    150 <dd>Print the current window to the default printer.</dd>
    151 <dt>Close</dt>
    152 <dd>Close the current window (ask to save if unsaved).</dd>
    153 <dt>Exit</dt>
    154 <dd>Close all windows and quit IDLE (ask to save unsaved windows).</dd>
    155 </dl>
    156 </div>
    157 <div class="section" id="edit-menu-shell-and-editor">
    158 <h3>25.5.1.2. Edit menu (Shell and Editor)<a class="headerlink" href="#edit-menu-shell-and-editor" title="Permalink to this headline"></a></h3>
    159 <dl class="docutils">
    160 <dt>Undo</dt>
    161 <dd>Undo the last change to the current window.  A maximum of 1000 changes may
    162 be undone.</dd>
    163 <dt>Redo</dt>
    164 <dd>Redo the last undone change to the current window.</dd>
    165 <dt>Cut</dt>
    166 <dd>Copy selection into the system-wide clipboard; then delete the selection.</dd>
    167 <dt>Copy</dt>
    168 <dd>Copy selection into the system-wide clipboard.</dd>
    169 <dt>Paste</dt>
    170 <dd>Insert contents of the system-wide clipboard into the current window.</dd>
    171 </dl>
    172 <p>The clipboard functions are also available in context menus.</p>
    173 <dl class="docutils">
    174 <dt>Select All</dt>
    175 <dd>Select the entire contents of the current window.</dd>
    176 <dt>Find...</dt>
    177 <dd>Open a search dialog with many options</dd>
    178 <dt>Find Again</dt>
    179 <dd>Repeat the last search, if there is one.</dd>
    180 <dt>Find Selection</dt>
    181 <dd>Search for the currently selected string, if there is one.</dd>
    182 <dt>Find in Files...</dt>
    183 <dd>Open a file search dialog.  Put results in a new output window.</dd>
    184 <dt>Replace...</dt>
    185 <dd>Open a search-and-replace dialog.</dd>
    186 <dt>Go to Line</dt>
    187 <dd>Move cursor to the line number requested and make that line visible.</dd>
    188 <dt>Show Completions</dt>
    189 <dd>Open a scrollable list allowing selection of keywords and attributes. See
    190 Completions in the Tips sections below.</dd>
    191 <dt>Expand Word</dt>
    192 <dd>Expand a prefix you have typed to match a full word in the same window;
    193 repeat to get a different expansion.</dd>
    194 <dt>Show call tip</dt>
    195 <dd>After an unclosed parenthesis for a function, open a small window with
    196 function parameter hints.</dd>
    197 <dt>Show surrounding parens</dt>
    198 <dd>Highlight the surrounding parenthesis.</dd>
    199 </dl>
    200 </div>
    201 <div class="section" id="format-menu-editor-window-only">
    202 <h3>25.5.1.3. Format menu (Editor window only)<a class="headerlink" href="#format-menu-editor-window-only" title="Permalink to this headline"></a></h3>
    203 <dl class="docutils">
    204 <dt>Indent Region</dt>
    205 <dd>Shift selected lines right by the indent width (default 4 spaces).</dd>
    206 <dt>Dedent Region</dt>
    207 <dd>Shift selected lines left by the indent width (default 4 spaces).</dd>
    208 <dt>Comment Out Region</dt>
    209 <dd>Insert ## in front of selected lines.</dd>
    210 <dt>Uncomment Region</dt>
    211 <dd>Remove leading # or ## from selected lines.</dd>
    212 <dt>Tabify Region</dt>
    213 <dd>Turn <em>leading</em> stretches of spaces into tabs. (Note: We recommend using
    214 4 space blocks to indent Python code.)</dd>
    215 <dt>Untabify Region</dt>
    216 <dd>Turn <em>all</em> tabs into the correct number of spaces.</dd>
    217 <dt>Toggle Tabs</dt>
    218 <dd>Open a dialog to switch between indenting with spaces and tabs.</dd>
    219 <dt>New Indent Width</dt>
    220 <dd>Open a dialog to change indent width. The accepted default by the Python
    221 community is 4 spaces.</dd>
    222 <dt>Format Paragraph</dt>
    223 <dd>Reformat the current blank-line-delimited paragraph in comment block or
    224 multiline string or selected line in a string.  All lines in the
    225 paragraph will be formatted to less than N columns, where N defaults to 72.</dd>
    226 <dt>Strip trailing whitespace</dt>
    227 <dd>Remove any space characters after the last non-space character of a line.</dd>
    228 </dl>
    229 </div>
    230 <div class="section" id="run-menu-editor-window-only">
    231 <span id="index-2"></span><h3>25.5.1.4. Run menu (Editor window only)<a class="headerlink" href="#run-menu-editor-window-only" title="Permalink to this headline"></a></h3>
    232 <dl class="docutils">
    233 <dt>Python Shell</dt>
    234 <dd>Open or wake up the Python Shell window.</dd>
    235 <dt>Check Module</dt>
    236 <dd>Check the syntax of the module currently open in the Editor window. If the
    237 module has not been saved IDLE will either prompt the user to save or
    238 autosave, as selected in the General tab of the Idle Settings dialog.  If
    239 there is a syntax error, the approximate location is indicated in the
    240 Editor window.</dd>
    241 <dt>Run Module</dt>
    242 <dd>Do Check Module (above).  If no error, restart the shell to clean the
    243 environment, then execute the module.  Output is displayed in the Shell
    244 window.  Note that output requires use of <code class="docutils literal"><span class="pre">print</span></code> or <code class="docutils literal"><span class="pre">write</span></code>.
    245 When execution is complete, the Shell retains focus and displays a prompt.
    246 At this point, one may interactively explore the result of execution.
    247 This is similar to executing a file with <code class="docutils literal"><span class="pre">python</span> <span class="pre">-i</span> <span class="pre">file</span></code> at a command
    248 line.</dd>
    249 </dl>
    250 </div>
    251 <div class="section" id="shell-menu-shell-window-only">
    252 <h3>25.5.1.5. Shell menu (Shell window only)<a class="headerlink" href="#shell-menu-shell-window-only" title="Permalink to this headline"></a></h3>
    253 <dl class="docutils">
    254 <dt>View Last Restart</dt>
    255 <dd>Scroll the shell window to the last Shell restart.</dd>
    256 <dt>Restart Shell</dt>
    257 <dd>Restart the shell to clean the environment.</dd>
    258 <dt>Interrupt Execution</dt>
    259 <dd>Stop a running program.</dd>
    260 </dl>
    261 </div>
    262 <div class="section" id="debug-menu-shell-window-only">
    263 <h3>25.5.1.6. Debug menu (Shell window only)<a class="headerlink" href="#debug-menu-shell-window-only" title="Permalink to this headline"></a></h3>
    264 <dl class="docutils">
    265 <dt>Go to File/Line</dt>
    266 <dd>Look on the current line. with the cursor, and the line above for a filename
    267 and line number.  If found, open the file if not already open, and show the
    268 line.  Use this to view source lines referenced in an exception traceback
    269 and lines found by Find in Files. Also available in the context menu of
    270 the Shell window and Output windows.</dd>
    271 </dl>
    272 <dl class="docutils" id="index-3">
    273 <dt>Debugger (toggle)</dt>
    274 <dd>When actived, code entered in the Shell or run from an Editor will run
    275 under the debugger.  In the Editor, breakpoints can be set with the context
    276 menu.  This feature is still incomplete and somewhat experimental.</dd>
    277 <dt>Stack Viewer</dt>
    278 <dd>Show the stack traceback of the last exception in a tree widget, with
    279 access to locals and globals.</dd>
    280 <dt>Auto-open Stack Viewer</dt>
    281 <dd>Toggle automatically opening the stack viewer on an unhandled exception.</dd>
    282 </dl>
    283 </div>
    284 <div class="section" id="options-menu-shell-and-editor">
    285 <h3>25.5.1.7. Options menu (Shell and Editor)<a class="headerlink" href="#options-menu-shell-and-editor" title="Permalink to this headline"></a></h3>
    286 <dl class="docutils">
    287 <dt>Configure IDLE</dt>
    288 <dd><p class="first">Open a configuration dialog and change preferences for the following:
    289 fonts, indentation, keybindings, text color themes, startup windows and
    290 size, additional help sources, and extensions (see below).  On OS X,
    291 open the configuration dialog by selecting Preferences in the application
    292 menu.  To use a new built-in color theme (IDLE Dark) with older IDLEs,
    293 save it as a new custom theme.</p>
    294 <p class="last">Non-default user settings are saved in a .idlerc directory in the user&#8217;s
    295 home directory.  Problems caused by bad user configuration files are solved
    296 by editing or deleting one or more of the files in .idlerc.</p>
    297 </dd>
    298 <dt>Code Context (toggle)(Editor Window only)</dt>
    299 <dd>Open a pane at the top of the edit window which shows the block context
    300 of the code which has scrolled above the top of the window.</dd>
    301 </dl>
    302 </div>
    303 <div class="section" id="window-menu-shell-and-editor">
    304 <h3>25.5.1.8. Window menu (Shell and Editor)<a class="headerlink" href="#window-menu-shell-and-editor" title="Permalink to this headline"></a></h3>
    305 <dl class="docutils">
    306 <dt>Zoom Height</dt>
    307 <dd>Toggles the window between normal size and maximum height. The initial size
    308 defaults to 40 lines by 80 chars unless changed on the General tab of the
    309 Configure IDLE dialog.</dd>
    310 </dl>
    311 <p>The rest of this menu lists the names of all open windows; select one to bring
    312 it to the foreground (deiconifying it if necessary).</p>
    313 </div>
    314 <div class="section" id="help-menu-shell-and-editor">
    315 <h3>25.5.1.9. Help menu (Shell and Editor)<a class="headerlink" href="#help-menu-shell-and-editor" title="Permalink to this headline"></a></h3>
    316 <dl class="docutils">
    317 <dt>About IDLE</dt>
    318 <dd>Display version, copyright, license, credits, and more.</dd>
    319 <dt>IDLE Help</dt>
    320 <dd>Display a help file for IDLE detailing the menu options, basic editing and
    321 navigation, and other tips.</dd>
    322 <dt>Python Docs</dt>
    323 <dd>Access local Python documentation, if installed, or start a web browser
    324 and open docs.python.org showing the latest Python documentation.</dd>
    325 <dt>Turtle Demo</dt>
    326 <dd>Run the turtledemo module with example python code and turtle drawings.</dd>
    327 </dl>
    328 <p>Additional help sources may be added here with the Configure IDLE dialog under
    329 the General tab.</p>
    330 </div>
    331 <div class="section" id="context-menus">
    332 <span id="index-4"></span><h3>25.5.1.10. Context Menus<a class="headerlink" href="#context-menus" title="Permalink to this headline"></a></h3>
    333 <p>Open a context menu by right-clicking in a window (Control-click on OS X).
    334 Context menus have the standard clipboard functions also on the Edit menu.</p>
    335 <dl class="docutils">
    336 <dt>Cut</dt>
    337 <dd>Copy selection into the system-wide clipboard; then delete the selection.</dd>
    338 <dt>Copy</dt>
    339 <dd>Copy selection into the system-wide clipboard.</dd>
    340 <dt>Paste</dt>
    341 <dd>Insert contents of the system-wide clipboard into the current window.</dd>
    342 </dl>
    343 <p>Editor windows also have breakpoint functions.  Lines with a breakpoint set are
    344 specially marked.  Breakpoints only have an effect when running under the
    345 debugger.  Breakpoints for a file are saved in the user&#8217;s .idlerc directory.</p>
    346 <dl class="docutils">
    347 <dt>Set Breakpoint</dt>
    348 <dd>Set a breakpoint on the current line.</dd>
    349 <dt>Clear Breakpoint</dt>
    350 <dd>Clear the breakpoint on that line.</dd>
    351 </dl>
    352 <p>Shell and Output windows have the following.</p>
    353 <dl class="docutils">
    354 <dt>Go to file/line</dt>
    355 <dd>Same as in Debug menu.</dd>
    356 </dl>
    357 </div>
    358 </div>
    359 <div class="section" id="editing-and-navigation">
    360 <h2>25.5.2. Editing and navigation<a class="headerlink" href="#editing-and-navigation" title="Permalink to this headline"></a></h2>
    361 <p>In this section, &#8216;C&#8217; refers to the <code class="kbd docutils literal"><span class="pre">Control</span></code> key on Windows and Unix and
    362 the <code class="kbd docutils literal"><span class="pre">Command</span></code> key on Mac OSX.</p>
    363 <ul>
    364 <li><p class="first"><code class="kbd docutils literal"><span class="pre">Backspace</span></code> deletes to the left; <code class="kbd docutils literal"><span class="pre">Del</span></code> deletes to the right</p>
    365 </li>
    366 <li><p class="first"><code class="kbd docutils literal"><span class="pre">C-Backspace</span></code> delete word left; <code class="kbd docutils literal"><span class="pre">C-Del</span></code> delete word to the right</p>
    367 </li>
    368 <li><p class="first">Arrow keys and <code class="kbd docutils literal"><span class="pre">Page</span> <span class="pre">Up</span></code>/<code class="kbd docutils literal"><span class="pre">Page</span> <span class="pre">Down</span></code> to move around</p>
    369 </li>
    370 <li><p class="first"><code class="kbd docutils literal"><span class="pre">C-LeftArrow</span></code> and <code class="kbd docutils literal"><span class="pre">C-RightArrow</span></code> moves by words</p>
    371 </li>
    372 <li><p class="first"><code class="kbd docutils literal"><span class="pre">Home</span></code>/<code class="kbd docutils literal"><span class="pre">End</span></code> go to begin/end of line</p>
    373 </li>
    374 <li><p class="first"><code class="kbd docutils literal"><span class="pre">C-Home</span></code>/<code class="kbd docutils literal"><span class="pre">C-End</span></code> go to begin/end of file</p>
    375 </li>
    376 <li><p class="first">Some useful Emacs bindings are inherited from Tcl/Tk:</p>
    377 <blockquote>
    378 <div><ul class="simple">
    379 <li><code class="kbd docutils literal"><span class="pre">C-a</span></code> beginning of line</li>
    380 <li><code class="kbd docutils literal"><span class="pre">C-e</span></code> end of line</li>
    381 <li><code class="kbd docutils literal"><span class="pre">C-k</span></code> kill line (but doesn&#8217;t put it in clipboard)</li>
    382 <li><code class="kbd docutils literal"><span class="pre">C-l</span></code> center window around the insertion point</li>
    383 <li><code class="kbd docutils literal"><span class="pre">C-b</span></code> go backwards one character without deleting (usually you can
    384 also use the cursor key for this)</li>
    385 <li><code class="kbd docutils literal"><span class="pre">C-f</span></code> go forward one character without deleting (usually you can
    386 also use the cursor key for this)</li>
    387 <li><code class="kbd docutils literal"><span class="pre">C-p</span></code> go up one line (usually you can also use the cursor key for
    388 this)</li>
    389 <li><code class="kbd docutils literal"><span class="pre">C-d</span></code> delete next character</li>
    390 </ul>
    391 </div></blockquote>
    392 </li>
    393 </ul>
    394 <p>Standard keybindings (like <code class="kbd docutils literal"><span class="pre">C-c</span></code> to copy and <code class="kbd docutils literal"><span class="pre">C-v</span></code> to paste)
    395 may work.  Keybindings are selected in the Configure IDLE dialog.</p>
    396 <div class="section" id="automatic-indentation">
    397 <h3>25.5.2.1. Automatic indentation<a class="headerlink" href="#automatic-indentation" title="Permalink to this headline"></a></h3>
    398 <p>After a block-opening statement, the next line is indented by 4 spaces (in the
    399 Python Shell window by one tab).  After certain keywords (break, return etc.)
    400 the next line is dedented.  In leading indentation, <code class="kbd docutils literal"><span class="pre">Backspace</span></code> deletes up
    401 to 4 spaces if they are there. <code class="kbd docutils literal"><span class="pre">Tab</span></code> inserts spaces (in the Python
    402 Shell window one tab), number depends on Indent width. Currently tabs
    403 are restricted to four spaces due to Tcl/Tk limitations.</p>
    404 <p>See also the indent/dedent region commands in the edit menu.</p>
    405 </div>
    406 <div class="section" id="completions">
    407 <h3>25.5.2.2. Completions<a class="headerlink" href="#completions" title="Permalink to this headline"></a></h3>
    408 <p>Completions are supplied for functions, classes, and attributes of classes,
    409 both built-in and user-defined. Completions are also provided for
    410 filenames.</p>
    411 <p>The AutoCompleteWindow (ACW) will open after a predefined delay (default is
    412 two seconds) after a &#8216;.&#8217; or (in a string) an os.sep is typed. If after one
    413 of those characters (plus zero or more other characters) a tab is typed
    414 the ACW will open immediately if a possible continuation is found.</p>
    415 <p>If there is only one possible completion for the characters entered, a
    416 <code class="kbd docutils literal"><span class="pre">Tab</span></code> will supply that completion without opening the ACW.</p>
    417 <p>&#8216;Show Completions&#8217; will force open a completions window, by default the
    418 <code class="kbd docutils literal"><span class="pre">C-space</span></code> will open a completions window. In an empty
    419 string, this will contain the files in the current directory. On a
    420 blank line, it will contain the built-in and user-defined functions and
    421 classes in the current name spaces, plus any modules imported. If some
    422 characters have been entered, the ACW will attempt to be more specific.</p>
    423 <p>If a string of characters is typed, the ACW selection will jump to the
    424 entry most closely matching those characters.  Entering a <code class="kbd docutils literal"><span class="pre">tab</span></code> will
    425 cause the longest non-ambiguous match to be entered in the Editor window or
    426 Shell.  Two <code class="kbd docutils literal"><span class="pre">tab</span></code> in a row will supply the current ACW selection, as
    427 will return or a double click.  Cursor keys, Page Up/Down, mouse selection,
    428 and the scroll wheel all operate on the ACW.</p>
    429 <p>&#8220;Hidden&#8221; attributes can be accessed by typing the beginning of hidden
    430 name after a &#8216;.&#8217;, e.g. &#8216;_&#8217;. This allows access to modules with
    431 <code class="docutils literal"><span class="pre">__all__</span></code> set, or to class-private attributes.</p>
    432 <p>Completions and the &#8216;Expand Word&#8217; facility can save a lot of typing!</p>
    433 <p>Completions are currently limited to those in the namespaces. Names in
    434 an Editor window which are not via <code class="docutils literal"><span class="pre">__main__</span></code> and <a class="reference internal" href="sys.html#sys.modules" title="sys.modules"><code class="xref py py-data docutils literal"><span class="pre">sys.modules</span></code></a> will
    435 not be found.  Run the module once with your imports to correct this situation.
    436 Note that IDLE itself places quite a few modules in sys.modules, so
    437 much can be found by default, e.g. the re module.</p>
    438 <p>If you don&#8217;t like the ACW popping up unbidden, simply make the delay
    439 longer or disable the extension.</p>
    440 </div>
    441 <div class="section" id="calltips">
    442 <h3>25.5.2.3. Calltips<a class="headerlink" href="#calltips" title="Permalink to this headline"></a></h3>
    443 <p>A calltip is shown when one types <code class="kbd docutils literal"><span class="pre">(</span></code> after the name of an <em>acccessible</em>
    444 function.  A name expression may include dots and subscripts.  A calltip
    445 remains until it is clicked, the cursor is moved out of the argument area,
    446 or <code class="kbd docutils literal"><span class="pre">)</span></code> is typed.  When the cursor is in the argument part of a definition,
    447 the menu or shortcut display a calltip.</p>
    448 <p>A calltip consists of the function signature and the first line of the
    449 docstring.  For builtins without an accessible signature, the calltip
    450 consists of all lines up the fifth line or the first blank line.  These
    451 details may change.</p>
    452 <p>The set of <em>accessible</em> functions depends on what modules have been imported
    453 into the user process, including those imported by Idle itself,
    454 and what definitions have been run, all since the last restart.</p>
    455 <p>For example, restart the Shell and enter <code class="docutils literal"><span class="pre">itertools.count(</span></code>.  A calltip
    456 appears because Idle imports itertools into the user process for its own use.
    457 (This could change.)  Enter <code class="docutils literal"><span class="pre">turtle.write(</span></code> and nothing appears.  Idle does
    458 not import turtle.  The menu or shortcut do nothing either.  Enter
    459 <code class="docutils literal"><span class="pre">import</span> <span class="pre">turtle</span></code> and then <code class="docutils literal"><span class="pre">turtle.write(</span></code> will work.</p>
    460 <p>In an editor, import statements have no effect until one runs the file.  One
    461 might want to run a file after writing the import statements at the top,
    462 or immediately run an existing file before editing.</p>
    463 </div>
    464 <div class="section" id="python-shell-window">
    465 <h3>25.5.2.4. Python Shell window<a class="headerlink" href="#python-shell-window" title="Permalink to this headline"></a></h3>
    466 <ul>
    467 <li><p class="first"><code class="kbd docutils literal"><span class="pre">C-c</span></code> interrupts executing command</p>
    468 </li>
    469 <li><p class="first"><code class="kbd docutils literal"><span class="pre">C-d</span></code> sends end-of-file; closes window if typed at a <code class="docutils literal"><span class="pre">&gt;&gt;&gt;</span></code> prompt</p>
    470 </li>
    471 <li><p class="first"><code class="kbd docutils literal"><span class="pre">Alt-/</span></code> (Expand word) is also useful to reduce typing</p>
    472 <p>Command history</p>
    473 <ul class="simple">
    474 <li><code class="kbd docutils literal"><span class="pre">Alt-p</span></code> retrieves previous command matching what you have typed. On
    475 OS X use <code class="kbd docutils literal"><span class="pre">C-p</span></code>.</li>
    476 <li><code class="kbd docutils literal"><span class="pre">Alt-n</span></code> retrieves next. On OS X use <code class="kbd docutils literal"><span class="pre">C-n</span></code>.</li>
    477 <li><code class="kbd docutils literal"><span class="pre">Return</span></code> while on any previous command retrieves that command</li>
    478 </ul>
    479 </li>
    480 </ul>
    481 </div>
    482 <div class="section" id="text-colors">
    483 <h3>25.5.2.5. Text colors<a class="headerlink" href="#text-colors" title="Permalink to this headline"></a></h3>
    484 <p>Idle defaults to black on white text, but colors text with special meanings.
    485 For the shell, these are shell output, shell error, user output, and
    486 user error.  For Python code, at the shell prompt or in an editor, these are
    487 keywords, builtin class and function names, names following <code class="docutils literal"><span class="pre">class</span></code> and
    488 <code class="docutils literal"><span class="pre">def</span></code>, strings, and comments. For any text window, these are the cursor (when
    489 present), found text (when possible), and selected text.</p>
    490 <p>Text coloring is done in the background, so uncolorized text is occasionally
    491 visible.  To change the color scheme, use the Configure IDLE dialog
    492 Highlighting tab.  The marking of debugger breakpoint lines in the editor and
    493 text in popups and dialogs is not user-configurable.</p>
    494 </div>
    495 </div>
    496 <div class="section" id="startup-and-code-execution">
    497 <h2>25.5.3. Startup and code execution<a class="headerlink" href="#startup-and-code-execution" title="Permalink to this headline"></a></h2>
    498 <p>Upon startup with the <code class="docutils literal"><span class="pre">-s</span></code> option, IDLE will execute the file referenced by
    499 the environment variables <span class="target" id="index-5"></span><code class="xref std std-envvar docutils literal"><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"><span class="pre">PYTHONSTARTUP</span></code></a>.
    500 IDLE first checks for <code class="docutils literal"><span class="pre">IDLESTARTUP</span></code>; if <code class="docutils literal"><span class="pre">IDLESTARTUP</span></code> is present the file
    501 referenced is run.  If <code class="docutils literal"><span class="pre">IDLESTARTUP</span></code> is not present, IDLE checks for
    502 <code class="docutils literal"><span class="pre">PYTHONSTARTUP</span></code>.  Files referenced by these environment variables are
    503 convenient places to store functions that are used frequently from the IDLE
    504 shell, or for executing import statements to import common modules.</p>
    505 <p>In addition, <code class="docutils literal"><span class="pre">Tk</span></code> also loads a startup file if it is present.  Note that the
    506 Tk file is loaded unconditionally.  This additional file is <code class="docutils literal"><span class="pre">.Idle.py</span></code> and is
    507 looked for in the user&#8217;s home directory.  Statements in this file will be
    508 executed in the Tk namespace, so this file is not useful for importing
    509 functions to be used from IDLE&#8217;s Python shell.</p>
    510 <div class="section" id="command-line-usage">
    511 <h3>25.5.3.1. Command line usage<a class="headerlink" href="#command-line-usage" title="Permalink to this headline"></a></h3>
    512 <div class="highlight-none"><div class="highlight"><pre><span></span>idle.py [-c command] [-d] [-e] [-h] [-i] [-r file] [-s] [-t title] [-] [arg] ...
    513 
    514 -c command  run command in the shell window
    515 -d          enable debugger and open shell window
    516 -e          open editor window
    517 -h          print help message with legal combinations and exit
    518 -i          open shell window
    519 -r file     run file in shell window
    520 -s          run $IDLESTARTUP or $PYTHONSTARTUP first, in shell window
    521 -t title    set title of shell window
    522 -           run stdin in shell (- must be last option before args)
    523 </pre></div>
    524 </div>
    525 <p>If there are arguments:</p>
    526 <ul class="simple">
    527 <li>If <code class="docutils literal"><span class="pre">-</span></code>, <code class="docutils literal"><span class="pre">-c</span></code>, or <code class="docutils literal"><span class="pre">r</span></code> is used, all arguments are placed in
    528 <code class="docutils literal"><span class="pre">sys.argv[1:...]</span></code> and <code class="docutils literal"><span class="pre">sys.argv[0]</span></code> is set to <code class="docutils literal"><span class="pre">''</span></code>, <code class="docutils literal"><span class="pre">'-c'</span></code>,
    529 or <code class="docutils literal"><span class="pre">'-r'</span></code>.  No editor window is opened, even if that is the default
    530 set in the Options dialog.</li>
    531 <li>Otherwise, arguments are files opened for editing and
    532 <code class="docutils literal"><span class="pre">sys.argv</span></code> reflects the arguments passed to IDLE itself.</li>
    533 </ul>
    534 </div>
    535 <div class="section" id="idle-console-differences">
    536 <h3>25.5.3.2. IDLE-console differences<a class="headerlink" href="#idle-console-differences" title="Permalink to this headline"></a></h3>
    537 <p>As much as possible, the result of executing Python code with IDLE is the
    538 same as executing the same code in a console window.  However, the different
    539 interface and operation occasionally affects visible results.  For instance,
    540 <code class="docutils literal"><span class="pre">sys.modules</span></code> starts with more entries.</p>
    541 <p>IDLE also replaces <code class="docutils literal"><span class="pre">sys.stdin</span></code>, <code class="docutils literal"><span class="pre">sys.stdout</span></code>, and <code class="docutils literal"><span class="pre">sys.stderr</span></code> with
    542 objects that get input from and send output to the Shell window.
    543 When this window has the focus, it controls the keyboard and screen.
    544 This is normally transparent, but functions that directly access the keyboard
    545 and screen will not work.  If <code class="docutils literal"><span class="pre">sys</span></code> is reset with <code class="docutils literal"><span class="pre">importlib.reload(sys)</span></code>,
    546 IDLE&#8217;s changes are lost and things like <code class="docutils literal"><span class="pre">input</span></code>, <code class="docutils literal"><span class="pre">raw_input</span></code>, and
    547 <code class="docutils literal"><span class="pre">print</span></code> will not work correctly.</p>
    548 <p>With IDLE&#8217;s Shell, one enters, edits, and recalls complete statements.
    549 Some consoles only work with a single physical line at a time.  IDLE uses
    550 <code class="docutils literal"><span class="pre">exec</span></code> to run each statement.  As a result, <code class="docutils literal"><span class="pre">'__builtins__'</span></code> is always
    551 defined for each statement.</p>
    552 </div>
    553 <div class="section" id="running-without-a-subprocess">
    554 <h3>25.5.3.3. Running without a subprocess<a class="headerlink" href="#running-without-a-subprocess" title="Permalink to this headline"></a></h3>
    555 <p>By default, IDLE executes user code in a separate subprocess via a socket,
    556 which uses the internal loopback interface.  This connection is not
    557 externally visible and no data is sent to or received from the Internet.
    558 If firewall software complains anyway, you can ignore it.</p>
    559 <p>If the attempt to make the socket connection fails, Idle will notify you.
    560 Such failures are sometimes transient, but if persistent, the problem
    561 may be either a firewall blocking the connecton or misconfiguration of
    562 a particular system.  Until the problem is fixed, one can run Idle with
    563 the -n command line switch.</p>
    564 <p>If IDLE is started with the -n command line switch it will run in a
    565 single process and will not create the subprocess which runs the RPC
    566 Python execution server.  This can be useful if Python cannot create
    567 the subprocess or the RPC socket interface on your platform.  However,
    568 in this mode user code is not isolated from IDLE itself.  Also, the
    569 environment is not restarted when Run/Run Module (F5) is selected.  If
    570 your code has been modified, you must reload() the affected modules and
    571 re-import any specific items (e.g. from foo import baz) if the changes
    572 are to take effect.  For these reasons, it is preferable to run IDLE
    573 with the default subprocess if at all possible.</p>
    574 <div class="deprecated">
    575 <p><span class="versionmodified">Deprecated since version 3.4.</span></p>
    576 </div>
    577 </div>
    578 </div>
    579 <div class="section" id="help-and-preferences">
    580 <h2>25.5.4. Help and preferences<a class="headerlink" href="#help-and-preferences" title="Permalink to this headline"></a></h2>
    581 <div class="section" id="additional-help-sources">
    582 <h3>25.5.4.1. Additional help sources<a class="headerlink" href="#additional-help-sources" title="Permalink to this headline"></a></h3>
    583 <p>IDLE includes a help menu entry called &#8220;Python Docs&#8221; that will open the
    584 extensive sources of help, including tutorials, available at docs.python.org.
    585 Selected URLs can be added or removed from the help menu at any time using the
    586 Configure IDLE dialog. See the IDLE help option in the help menu of IDLE for
    587 more information.</p>
    588 </div>
    589 <div class="section" id="setting-preferences">
    590 <h3>25.5.4.2. Setting preferences<a class="headerlink" href="#setting-preferences" title="Permalink to this headline"></a></h3>
    591 <p>The font preferences, highlighting, keys, and general preferences can be
    592 changed via Configure IDLE on the Option menu.  Keys can be user defined;
    593 IDLE ships with four built in key sets. In addition a user can create a
    594 custom key set in the Configure IDLE dialog under the keys tab.</p>
    595 </div>
    596 <div class="section" id="extensions">
    597 <h3>25.5.4.3. Extensions<a class="headerlink" href="#extensions" title="Permalink to this headline"></a></h3>
    598 <p>IDLE contains an extension facility.  Peferences for extensions can be
    599 changed with Configure Extensions. See the beginning of config-extensions.def
    600 in the idlelib directory for further information.  The default extensions
    601 are currently:</p>
    602 <ul class="simple">
    603 <li>FormatParagraph</li>
    604 <li>AutoExpand</li>
    605 <li>ZoomHeight</li>
    606 <li>ScriptBinding</li>
    607 <li>CallTips</li>
    608 <li>ParenMatch</li>
    609 <li>AutoComplete</li>
    610 <li>CodeContext</li>
    611 <li>RstripExtension</li>
    612 </ul>
    613 </div>
    614 </div>
    615 </div>
    616 
    617 
    618           </div>
    619         </div>
    620       </div>
    621       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
    622         <div class="sphinxsidebarwrapper">
    623   <h3><a href="../contents.html">Table Of Contents</a></h3>
    624   <ul>
    625 <li><a class="reference internal" href="#">25.5. IDLE</a><ul>
    626 <li><a class="reference internal" href="#menus">25.5.1. Menus</a><ul>
    627 <li><a class="reference internal" href="#file-menu-shell-and-editor">25.5.1.1. File menu (Shell and Editor)</a></li>
    628 <li><a class="reference internal" href="#edit-menu-shell-and-editor">25.5.1.2. Edit menu (Shell and Editor)</a></li>
    629 <li><a class="reference internal" href="#format-menu-editor-window-only">25.5.1.3. Format menu (Editor window only)</a></li>
    630 <li><a class="reference internal" href="#run-menu-editor-window-only">25.5.1.4. Run menu (Editor window only)</a></li>
    631 <li><a class="reference internal" href="#shell-menu-shell-window-only">25.5.1.5. Shell menu (Shell window only)</a></li>
    632 <li><a class="reference internal" href="#debug-menu-shell-window-only">25.5.1.6. Debug menu (Shell window only)</a></li>
    633 <li><a class="reference internal" href="#options-menu-shell-and-editor">25.5.1.7. Options menu (Shell and Editor)</a></li>
    634 <li><a class="reference internal" href="#window-menu-shell-and-editor">25.5.1.8. Window menu (Shell and Editor)</a></li>
    635 <li><a class="reference internal" href="#help-menu-shell-and-editor">25.5.1.9. Help menu (Shell and Editor)</a></li>
    636 <li><a class="reference internal" href="#context-menus">25.5.1.10. Context Menus</a></li>
    637 </ul>
    638 </li>
    639 <li><a class="reference internal" href="#editing-and-navigation">25.5.2. Editing and navigation</a><ul>
    640 <li><a class="reference internal" href="#automatic-indentation">25.5.2.1. Automatic indentation</a></li>
    641 <li><a class="reference internal" href="#completions">25.5.2.2. Completions</a></li>
    642 <li><a class="reference internal" href="#calltips">25.5.2.3. Calltips</a></li>
    643 <li><a class="reference internal" href="#python-shell-window">25.5.2.4. Python Shell window</a></li>
    644 <li><a class="reference internal" href="#text-colors">25.5.2.5. Text colors</a></li>
    645 </ul>
    646 </li>
    647 <li><a class="reference internal" href="#startup-and-code-execution">25.5.3. Startup and code execution</a><ul>
    648 <li><a class="reference internal" href="#command-line-usage">25.5.3.1. Command line usage</a></li>
    649 <li><a class="reference internal" href="#idle-console-differences">25.5.3.2. IDLE-console differences</a></li>
    650 <li><a class="reference internal" href="#running-without-a-subprocess">25.5.3.3. Running without a subprocess</a></li>
    651 </ul>
    652 </li>
    653 <li><a class="reference internal" href="#help-and-preferences">25.5.4. Help and preferences</a><ul>
    654 <li><a class="reference internal" href="#additional-help-sources">25.5.4.1. Additional help sources</a></li>
    655 <li><a class="reference internal" href="#setting-preferences">25.5.4.2. Setting preferences</a></li>
    656 <li><a class="reference internal" href="#extensions">25.5.4.3. Extensions</a></li>
    657 </ul>
    658 </li>
    659 </ul>
    660 </li>
    661 </ul>
    662 
    663   <h4>Previous topic</h4>
    664   <p class="topless"><a href="tkinter.scrolledtext.html"
    665                         title="previous chapter">25.4. <code class="docutils literal"><span class="pre">tkinter.scrolledtext</span></code> &#8212; Scrolled Text Widget</a></p>
    666   <h4>Next topic</h4>
    667   <p class="topless"><a href="othergui.html"
    668                         title="next chapter">25.6. Other Graphical User Interface Packages</a></p>
    669   <div role="note" aria-label="source link">
    670     <h3>This Page</h3>
    671     <ul class="this-page-menu">
    672       <li><a href="../bugs.html">Report a Bug</a></li>
    673       <li><a href="../_sources/library/idle.txt"
    674             rel="nofollow">Show Source</a></li>
    675     </ul>
    676   </div>
    677         </div>
    678       </div>
    679       <div class="clearer"></div>
    680     </div>
    681     <div class="related" role="navigation" aria-label="related navigation">
    682       <h3>Navigation</h3>
    683       <ul>
    684         <li class="right" style="margin-right: 10px">
    685           <a href="../genindex.html" title="General Index"
    686              >index</a></li>
    687         <li class="right" >
    688           <a href="../py-modindex.html" title="Python Module Index"
    689              >modules</a> |</li>
    690         <li class="right" >
    691           <a href="othergui.html" title="25.6. Other Graphical User Interface Packages"
    692              >next</a> |</li>
    693         <li class="right" >
    694           <a href="tkinter.scrolledtext.html" title="25.4. tkinter.scrolledtext  Scrolled Text Widget"
    695              >previous</a> |</li>
    696         <li><img src="../_static/py.png" alt=""
    697                  style="vertical-align: middle; margin-top: -1px"/></li>
    698         <li><a href="https://www.python.org/">Python</a> &raquo;</li>
    699         <li>
    700           <a href="../index.html">3.5.2 Documentation</a> &raquo;
    701         </li>
    702 
    703           <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &raquo;</li>
    704           <li class="nav-item nav-item-2"><a href="tk.html" >25. Graphical User Interfaces with Tk</a> &raquo;</li>
    705     <li class="right">
    706 
    707 
    708     <div class="inline-search" style="display: none" role="search">
    709         <form class="inline-search" action="../search.html" method="get">
    710           <input placeholder="Quick search" type="text" name="q" />
    711           <input type="submit" value="Go" />
    712           <input type="hidden" name="check_keywords" value="yes" />
    713           <input type="hidden" name="area" value="default" />
    714         </form>
    715     </div>
    716     <script type="text/javascript">$('.inline-search').show(0);</script>
    717          |
    718     </li>
    719 
    720       </ul>
    721     </div>
    722     <div class="footer">
    723     &copy; <a href="../copyright.html">Copyright</a> 2001-2016, Python Software Foundation.
    724     <br />
    725     The Python Software Foundation is a non-profit corporation.
    726     <a href="https://www.python.org/psf/donations/">Please donate.</a>
    727     <br />
    728     Last updated on Sep 12, 2016.
    729     <a href="../bugs.html">Found a bug</a>?
    730     <br />
    731     Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.3.6.
    732     </div>
    733 
    734   </body>
    735 </html>
    736