Server : Apache System : Linux server1.cgrithy.com 3.10.0-1160.95.1.el7.x86_64 #1 SMP Mon Jul 24 13:59:37 UTC 2023 x86_64 User : nobody ( 99) PHP Version : 8.1.23 Disable Function : NONE Directory : /usr/share/doc/python-docs-2.7.5/html/library/ |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>24.6. IDLE — Python 2.7.5 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '2.7.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/sidebar.js"></script> <link rel="search" type="application/opensearchdescription+xml" title="Search within Python 2.7.5 documentation" href="../_static/opensearch.xml"/> <link rel="author" title="About these documents" href="../about.html" /> <link rel="copyright" title="Copyright" href="../copyright.html" /> <link rel="top" title="Python 2.7.5 documentation" href="../index.html" /> <link rel="up" title="24. Graphical User Interfaces with Tk" href="tk.html" /> <link rel="next" title="24.7. Other Graphical User Interface Packages" href="othergui.html" /> <link rel="prev" title="24.5. turtle — Turtle graphics for Tk" href="turtle.html" /> <link rel="shortcut icon" type="image/png" href="../_static/py.png" /> <script type="text/javascript" src="../_static/copybutton.js"></script> </head> <body> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="othergui.html" title="24.7. Other Graphical User Interface Packages" accesskey="N">next</a> |</li> <li class="right" > <a href="turtle.html" title="24.5. turtle — Turtle graphics for Tk" accesskey="P">previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="http://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.5 documentation</a> » </li> <li><a href="index.html" >The Python Standard Library</a> »</li> <li><a href="tk.html" accesskey="U">24. Graphical User Interfaces with Tk</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="idle"> <span id="id1"></span><h1>24.6. IDLE<a class="headerlink" href="#idle" title="Permalink to this headline">¶</a></h1> <p id="index-0">IDLE is the Python IDE built with the <tt class="xref py py-mod docutils literal"><span class="pre">tkinter</span></tt> GUI toolkit.</p> <p>IDLE has the following features:</p> <ul class="simple"> <li>coded in 100% pure Python, using the <tt class="xref py py-mod docutils literal"><span class="pre">tkinter</span></tt> GUI toolkit</li> <li>cross-platform: works on Windows and Unix</li> <li>multi-window text editor with multiple undo, Python colorizing and many other features, e.g. smart indent and call tips</li> <li>Python shell window (a.k.a. interactive interpreter)</li> <li>debugger (not complete, but you can set breakpoints, view and step)</li> </ul> <div class="section" id="menus"> <h2>24.6.1. Menus<a class="headerlink" href="#menus" title="Permalink to this headline">¶</a></h2> <div class="section" id="file-menu"> <h3>24.6.1.1. File menu<a class="headerlink" href="#file-menu" title="Permalink to this headline">¶</a></h3> <dl class="docutils"> <dt>New window</dt> <dd>create a new editing window</dd> <dt>Open...</dt> <dd>open an existing file</dd> <dt>Open module...</dt> <dd>open an existing module (searches sys.path)</dd> <dt>Class browser</dt> <dd>show classes and methods in current file</dd> <dt>Path browser</dt> <dd>show sys.path directories, modules, classes and methods</dd> </dl> <dl class="docutils" id="index-1"> <dt>Save</dt> <dd>save current window to the associated file (unsaved windows have a * before and after the window title)</dd> <dt>Save As...</dt> <dd>save current window to new file, which becomes the associated file</dd> <dt>Save Copy As...</dt> <dd>save current window to different file without changing the associated file</dd> <dt>Close</dt> <dd>close current window (asks to save if unsaved)</dd> <dt>Exit</dt> <dd>close all windows and quit IDLE (asks to save if unsaved)</dd> </dl> </div> <div class="section" id="edit-menu"> <h3>24.6.1.2. Edit menu<a class="headerlink" href="#edit-menu" title="Permalink to this headline">¶</a></h3> <dl class="docutils"> <dt>Undo</dt> <dd>Undo last change to current window (max 1000 changes)</dd> <dt>Redo</dt> <dd>Redo last undone change to current window</dd> <dt>Cut</dt> <dd>Copy selection into system-wide clipboard; then delete selection</dd> <dt>Copy</dt> <dd>Copy selection into system-wide clipboard</dd> <dt>Paste</dt> <dd>Insert system-wide clipboard into window</dd> <dt>Select All</dt> <dd>Select the entire contents of the edit buffer</dd> <dt>Find...</dt> <dd>Open a search dialog box with many options</dd> <dt>Find again</dt> <dd>Repeat last search</dd> <dt>Find selection</dt> <dd>Search for the string in the selection</dd> <dt>Find in Files...</dt> <dd>Open a search dialog box for searching files</dd> <dt>Replace...</dt> <dd>Open a search-and-replace dialog box</dd> <dt>Go to line</dt> <dd>Ask for a line number and show that line</dd> <dt>Indent region</dt> <dd>Shift selected lines right 4 spaces</dd> <dt>Dedent region</dt> <dd>Shift selected lines left 4 spaces</dd> <dt>Comment out region</dt> <dd>Insert ## in front of selected lines</dd> <dt>Uncomment region</dt> <dd>Remove leading # or ## from selected lines</dd> <dt>Tabify region</dt> <dd>Turns <em>leading</em> stretches of spaces into tabs</dd> <dt>Untabify region</dt> <dd>Turn <em>all</em> tabs into the right number of spaces</dd> <dt>Expand word</dt> <dd>Expand the word you have typed to match another word in the same buffer; repeat to get a different expansion</dd> <dt>Format Paragraph</dt> <dd>Reformat the current blank-line-separated paragraph</dd> <dt>Import module</dt> <dd>Import or reload the current module</dd> <dt>Run script</dt> <dd>Execute the current file in the __main__ namespace</dd> </dl> </div> <div class="section" id="windows-menu"> <span id="index-2"></span><h3>24.6.1.3. Windows menu<a class="headerlink" href="#windows-menu" title="Permalink to this headline">¶</a></h3> <dl class="docutils"> <dt>Zoom Height</dt> <dd>toggles the window between normal size (24x80) and maximum height.</dd> </dl> <p>The rest of this menu lists the names of all open windows; select one to bring it to the foreground (deiconifying it if necessary).</p> </div> <div class="section" id="debug-menu"> <h3>24.6.1.4. Debug menu<a class="headerlink" href="#debug-menu" title="Permalink to this headline">¶</a></h3> <ul class="simple"> <li>in the Python Shell window only</li> </ul> <dl class="docutils"> <dt>Go to file/line</dt> <dd>Look around the insert point for a filename and line number, open the file, and show the line. Useful to view the source lines referenced in an exception traceback.</dd> <dt>Debugger</dt> <dd>Run commands in the shell under the debugger.</dd> <dt>Stack viewer</dt> <dd>Show the stack traceback of the last exception.</dd> <dt>Auto-open Stack Viewer</dt> <dd>Open stack viewer on traceback.</dd> </dl> </div> <div class="section" id="edit-context-menu"> <span id="index-3"></span><h3>24.6.1.5. Edit context menu<a class="headerlink" href="#edit-context-menu" title="Permalink to this headline">¶</a></h3> <ul class="simple"> <li>Right-click in Edit window (Control-click on OS X)</li> </ul> <dl class="docutils"> <dt>Cut</dt> <dd>Copy selection into system-wide clipboard; then delete selection</dd> <dt>Copy</dt> <dd>Copy selection into system-wide clipboard</dd> <dt>Paste</dt> <dd>Insert system-wide clipboard into window</dd> <dt>Set Breakpoint</dt> <dd>Sets a breakpoint. Breakpoints are only enabled when the debugger is open.</dd> <dt>Clear Breakpoint</dt> <dd>Clears the breakpoint on that line.</dd> </dl> </div> <div class="section" id="shell-context-menu"> <span id="index-4"></span><h3>24.6.1.6. Shell context menu<a class="headerlink" href="#shell-context-menu" title="Permalink to this headline">¶</a></h3> <ul class="simple"> <li>Right-click in Python Shell window (Control-click on OS X)</li> </ul> <dl class="docutils"> <dt>Cut</dt> <dd>Copy selection into system-wide clipboard; then delete selection</dd> <dt>Copy</dt> <dd>Copy selection into system-wide clipboard</dd> <dt>Paste</dt> <dd>Insert system-wide clipboard into window</dd> <dt>Go to file/line</dt> <dd>Same as in Debug menu.</dd> </dl> </div> </div> <div class="section" id="basic-editing-and-navigation"> <h2>24.6.2. Basic editing and navigation<a class="headerlink" href="#basic-editing-and-navigation" title="Permalink to this headline">¶</a></h2> <ul class="simple"> <li><tt class="kbd docutils literal"><span class="pre">Backspace</span></tt> deletes to the left; <tt class="kbd docutils literal"><span class="pre">Del</span></tt> deletes to the right</li> <li>Arrow keys and <tt class="kbd docutils literal"><span class="pre">Page</span> <span class="pre">Up</span></tt>/<tt class="kbd docutils literal"><span class="pre">Page</span> <span class="pre">Down</span></tt> to move around</li> <li><tt class="kbd docutils literal"><span class="pre">Home</span></tt>/<tt class="kbd docutils literal"><span class="pre">End</span></tt> go to begin/end of line</li> <li><tt class="kbd docutils literal"><span class="pre">C-Home</span></tt>/<tt class="kbd docutils literal"><span class="pre">C-End</span></tt> go to begin/end of file</li> <li>Some <strong class="program">Emacs</strong> bindings may also work, including <tt class="kbd docutils literal"><span class="pre">C-B</span></tt>, <tt class="kbd docutils literal"><span class="pre">C-P</span></tt>, <tt class="kbd docutils literal"><span class="pre">C-A</span></tt>, <tt class="kbd docutils literal"><span class="pre">C-E</span></tt>, <tt class="kbd docutils literal"><span class="pre">C-D</span></tt>, <tt class="kbd docutils literal"><span class="pre">C-L</span></tt></li> </ul> <div class="section" id="automatic-indentation"> <h3>24.6.2.1. Automatic indentation<a class="headerlink" href="#automatic-indentation" title="Permalink to this headline">¶</a></h3> <p>After a block-opening statement, the next line is indented by 4 spaces (in the Python Shell window by one tab). After certain keywords (break, return etc.) the next line is dedented. In leading indentation, <tt class="kbd docutils literal"><span class="pre">Backspace</span></tt> deletes up to 4 spaces if they are there. <tt class="kbd docutils literal"><span class="pre">Tab</span></tt> inserts 1-4 spaces (in the Python Shell window one tab). See also the indent/dedent region commands in the edit menu.</p> </div> <div class="section" id="python-shell-window"> <h3>24.6.2.2. Python Shell window<a class="headerlink" href="#python-shell-window" title="Permalink to this headline">¶</a></h3> <ul class="simple"> <li><tt class="kbd docutils literal"><span class="pre">C-C</span></tt> interrupts executing command</li> <li><tt class="kbd docutils literal"><span class="pre">C-D</span></tt> sends end-of-file; closes window if typed at a <tt class="docutils literal"><span class="pre">>>></span></tt> prompt</li> <li><tt class="kbd docutils literal"><span class="pre">Alt-p</span></tt> retrieves previous command matching what you have typed</li> <li><tt class="kbd docutils literal"><span class="pre">Alt-n</span></tt> retrieves next</li> <li><tt class="kbd docutils literal"><span class="pre">Return</span></tt> while on any previous command retrieves that command</li> <li><tt class="kbd docutils literal"><span class="pre">Alt-/</span></tt> (Expand word) is also useful here</li> </ul> </div> </div> <div class="section" id="syntax-colors"> <span id="index-5"></span><h2>24.6.3. Syntax colors<a class="headerlink" href="#syntax-colors" title="Permalink to this headline">¶</a></h2> <p>The coloring is applied in a background “thread,” so you may occasionally see uncolorized text. To change the color scheme, edit the <tt class="docutils literal"><span class="pre">[Colors]</span></tt> section in <tt class="file docutils literal"><span class="pre">config.txt</span></tt>.</p> <dl class="docutils"> <dt>Python syntax colors:</dt> <dd><dl class="first last docutils"> <dt>Keywords</dt> <dd>orange</dd> <dt>Strings</dt> <dd>green</dd> <dt>Comments</dt> <dd>red</dd> <dt>Definitions</dt> <dd>blue</dd> </dl> </dd> <dt>Shell colors:</dt> <dd><dl class="first last docutils"> <dt>Console output</dt> <dd>brown</dd> <dt>stdout</dt> <dd>blue</dd> <dt>stderr</dt> <dd>dark green</dd> <dt>stdin</dt> <dd>black</dd> </dl> </dd> </dl> </div> <div class="section" id="startup"> <h2>24.6.4. Startup<a class="headerlink" href="#startup" title="Permalink to this headline">¶</a></h2> <p>Upon startup with the <tt class="docutils literal"><span class="pre">-s</span></tt> option, IDLE will execute the file referenced by the environment variables <span class="target" id="index-6"></span><tt class="xref std std-envvar docutils literal"><span class="pre">IDLESTARTUP</span></tt> or <span class="target" id="index-7"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONSTARTUP"><tt class="xref std std-envvar docutils literal"><span class="pre">PYTHONSTARTUP</span></tt></a>. Idle first checks for <tt class="docutils literal"><span class="pre">IDLESTARTUP</span></tt>; if <tt class="docutils literal"><span class="pre">IDLESTARTUP</span></tt> is present the file referenced is run. If <tt class="docutils literal"><span class="pre">IDLESTARTUP</span></tt> is not present, Idle checks for <tt class="docutils literal"><span class="pre">PYTHONSTARTUP</span></tt>. Files referenced by these environment variables are convenient places to store functions that are used frequently from the Idle shell, or for executing import statements to import common modules.</p> <p>In addition, <tt class="docutils literal"><span class="pre">Tk</span></tt> also loads a startup file if it is present. Note that the Tk file is loaded unconditionally. This additional file is <tt class="docutils literal"><span class="pre">.Idle.py</span></tt> and is looked for in the user’s home directory. Statements in this file will be executed in the Tk namespace, so this file is not useful for importing functions to be used from Idle’s Python shell.</p> <div class="section" id="command-line-usage"> <h3>24.6.4.1. Command line usage<a class="headerlink" href="#command-line-usage" title="Permalink to this headline">¶</a></h3> <div class="highlight-python"><pre>idle.py [-c command] [-d] [-e] [-s] [-t title] [arg] ... -c command run this command -d enable debugger -e edit mode; arguments are files to be edited -s run $IDLESTARTUP or $PYTHONSTARTUP first -t title set title of shell window</pre> </div> <p>If there are arguments:</p> <ol class="arabic simple"> <li>If <tt class="docutils literal"><span class="pre">-e</span></tt> is used, arguments are files opened for editing and <tt class="docutils literal"><span class="pre">sys.argv</span></tt> reflects the arguments passed to IDLE itself.</li> <li>Otherwise, if <tt class="docutils literal"><span class="pre">-c</span></tt> is used, all arguments are placed in <tt class="docutils literal"><span class="pre">sys.argv[1:...]</span></tt>, with <tt class="docutils literal"><span class="pre">sys.argv[0]</span></tt> set to <tt class="docutils literal"><span class="pre">'-c'</span></tt>.</li> <li>Otherwise, if neither <tt class="docutils literal"><span class="pre">-e</span></tt> nor <tt class="docutils literal"><span class="pre">-c</span></tt> is used, the first argument is a script which is executed with the remaining arguments in <tt class="docutils literal"><span class="pre">sys.argv[1:...]</span></tt> and <tt class="docutils literal"><span class="pre">sys.argv[0]</span></tt> set to the script name. If the script name is ‘-‘, no script is executed but an interactive Python session is started; the arguments are still available in <tt class="docutils literal"><span class="pre">sys.argv</span></tt>.</li> </ol> </div> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="../contents.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">24.6. IDLE</a><ul> <li><a class="reference internal" href="#menus">24.6.1. Menus</a><ul> <li><a class="reference internal" href="#file-menu">24.6.1.1. File menu</a></li> <li><a class="reference internal" href="#edit-menu">24.6.1.2. Edit menu</a></li> <li><a class="reference internal" href="#windows-menu">24.6.1.3. Windows menu</a></li> <li><a class="reference internal" href="#debug-menu">24.6.1.4. Debug menu</a></li> <li><a class="reference internal" href="#edit-context-menu">24.6.1.5. Edit context menu</a></li> <li><a class="reference internal" href="#shell-context-menu">24.6.1.6. Shell context menu</a></li> </ul> </li> <li><a class="reference internal" href="#basic-editing-and-navigation">24.6.2. Basic editing and navigation</a><ul> <li><a class="reference internal" href="#automatic-indentation">24.6.2.1. Automatic indentation</a></li> <li><a class="reference internal" href="#python-shell-window">24.6.2.2. Python Shell window</a></li> </ul> </li> <li><a class="reference internal" href="#syntax-colors">24.6.3. Syntax colors</a></li> <li><a class="reference internal" href="#startup">24.6.4. Startup</a><ul> <li><a class="reference internal" href="#command-line-usage">24.6.4.1. Command line usage</a></li> </ul> </li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="turtle.html" title="previous chapter">24.5. <tt class="docutils literal"><span class="pre">turtle</span></tt> — Turtle graphics for Tk</a></p> <h4>Next topic</h4> <p class="topless"><a href="othergui.html" title="next chapter">24.7. Other Graphical User Interface Packages</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../bugs.html">Report a Bug</a></li> <li><a href="../_sources/library/idle.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="othergui.html" title="24.7. Other Graphical User Interface Packages" >next</a> |</li> <li class="right" > <a href="turtle.html" title="24.5. turtle — Turtle graphics for Tk" >previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="http://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.5 documentation</a> » </li> <li><a href="index.html" >The Python Standard Library</a> »</li> <li><a href="tk.html" >24. Graphical User Interfaces with Tk</a> »</li> </ul> </div> <div class="footer"> © <a href="../copyright.html">Copyright</a> 1990-2020, Python Software Foundation. <br /> The Python Software Foundation is a non-profit corporation. <a href="http://www.python.org/psf/donations/">Please donate.</a> <br /> Last updated on Oct 13, 2020. <a href="../bugs.html">Found a bug</a>? <br /> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. </div> </body> </html>