blob: 33ae884205556378effbf89f9416ada569f79db7 [file] [log] [blame]
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -04001<!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" />
Terry Jan Reedy963a38b2015-09-20 20:03:01 -04008
terryjreedy188aedf2017-06-13 21:32:16 -04009 <title>25.5. IDLE &mdash; Python 3.7.0a0 documentation</title>
Terry Jan Reedy963a38b2015-09-20 20:03:01 -040010
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -040011 <link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
12 <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
Terry Jan Reedy963a38b2015-09-20 20:03:01 -040013
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -040014 <script type="text/javascript">
15 var DOCUMENTATION_OPTIONS = {
16 URL_ROOT: '../',
terryjreedy188aedf2017-06-13 21:32:16 -040017 VERSION: '3.7.0a0',
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -040018 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"
terryjreedy188aedf2017-06-13 21:32:16 -040028 title="Search within Python 3.7.0a0 documentation"
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -040029 href="../_static/opensearch.xml"/>
30 <link rel="author" title="About these documents" href="../about.html" />
31 <link rel="copyright" title="Copyright" href="../copyright.html" />
terryjreedy188aedf2017-06-13 21:32:16 -040032 <link rel="top" title="Python 3.7.0a0 documentation" href="../contents.html" />
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -040033 <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" />
terryjreedy188aedf2017-06-13 21:32:16 -040037 <link rel="canonical" href="https://docs.python.org/3/library/idle.html" />
38
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -040039 <script type="text/javascript" src="../_static/copybutton.js"></script>
Terry Jan Reedy963a38b2015-09-20 20:03:01 -040040
41
42
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -040043
terryjreedy188aedf2017-06-13 21:32:16 -040044
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -040045 </head>
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -050046 <body role="document">
47 <div class="related" role="navigation" aria-label="related navigation">
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -040048 <h3>Navigation</h3>
49 <ul>
50 <li class="right" style="margin-right: 10px">
51 <a href="../genindex.html" title="General Index"
52 accesskey="I">index</a></li>
53 <li class="right" >
54 <a href="../py-modindex.html" title="Python Module Index"
55 >modules</a> |</li>
56 <li class="right" >
57 <a href="othergui.html" title="25.6. Other Graphical User Interface Packages"
58 accesskey="N">next</a> |</li>
59 <li class="right" >
60 <a href="tkinter.scrolledtext.html" title="25.4. tkinter.scrolledtext — Scrolled Text Widget"
61 accesskey="P">previous</a> |</li>
62 <li><img src="../_static/py.png" alt=""
63 style="vertical-align: middle; margin-top: -1px"/></li>
Terry Jan Reedy3399e1e2016-08-30 16:58:01 -040064 <li><a href="https://www.python.org/">Python</a> &raquo;</li>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -040065 <li>
terryjreedy188aedf2017-06-13 21:32:16 -040066 <a href="../index.html">3.7.0a0 Documentation</a> &raquo;
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -040067 </li>
68
Terry Jan Reedy3399e1e2016-08-30 16:58:01 -040069 <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &raquo;</li>
70 <li class="nav-item nav-item-2"><a href="tk.html" accesskey="U">25. Graphical User Interfaces with Tk</a> &raquo;</li>
Terry Jan Reedy4b736762016-09-12 01:50:03 -040071 <li class="right">
72
73
74 <div class="inline-search" style="display: none" role="search">
75 <form class="inline-search" action="../search.html" method="get">
76 <input placeholder="Quick search" type="text" name="q" />
77 <input type="submit" value="Go" />
78 <input type="hidden" name="check_keywords" value="yes" />
79 <input type="hidden" name="area" value="default" />
80 </form>
81 </div>
82 <script type="text/javascript">$('.inline-search').show(0);</script>
83 |
84 </li>
85
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -040086 </ul>
Terry Jan Reedy963a38b2015-09-20 20:03:01 -040087 </div>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -040088
89 <div class="document">
90 <div class="documentwrapper">
91 <div class="bodywrapper">
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -050092 <div class="body" role="main">
Terry Jan Reedy963a38b2015-09-20 20:03:01 -040093
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -040094 <div class="section" id="idle">
95<span id="id1"></span><h1>25.5. IDLE<a class="headerlink" href="#idle" title="Permalink to this headline"></a></h1>
terryjreedy188aedf2017-06-13 21:32:16 -040096<p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/master/Lib/idlelib/">Lib/idlelib/</a></p>
Terry Jan Reedyfa089b92016-06-11 15:02:54 -040097<hr class="docutils" id="index-0" />
98<p>IDLE is Python&#8217;s Integrated Development and Learning Environment.</p>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -040099<p>IDLE has the following features:</p>
100<ul class="simple">
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500101<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>
Terry Jan Reedy0053c472015-09-24 03:09:43 -0400102<li>cross-platform: works mostly the same on Windows, Unix, and Mac OS X</li>
Terry Jan Reedy6e10ec52015-09-23 20:00:33 -0400103<li>Python shell window (interactive interpreter) with colorizing
104of code input, output, and error messages</li>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400105<li>multi-window text editor with multiple undo, Python colorizing,
Terry Jan Reedy6e10ec52015-09-23 20:00:33 -0400106smart indent, call tips, auto completion, and other features</li>
107<li>search within any window, replace within editor windows, and search
108through multiple files (grep)</li>
109<li>debugger with persistent breakpoints, stepping, and viewing
110of global and local namespaces</li>
111<li>configuration, browsers, and other dialogs</li>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400112</ul>
113<div class="section" id="menus">
114<h2>25.5.1. Menus<a class="headerlink" href="#menus" title="Permalink to this headline"></a></h2>
115<p>IDLE has two main window types, the Shell window and the Editor window. It is
116possible to have multiple editor windows simultaneously. Output windows, such
117as used for Edit / Find in Files, are a subtype of edit window. They currently
118have the same top menu as Editor windows but a different default title and
119context menu.</p>
120<p>IDLE&#8217;s menus dynamically change based on which window is currently selected.
121Each menu documented below indicates which window type it is associated with.</p>
122<div class="section" id="file-menu-shell-and-editor">
123<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>
124<dl class="docutils">
125<dt>New File</dt>
126<dd>Create a new file editing window.</dd>
127<dt>Open...</dt>
128<dd>Open an existing file with an Open dialog.</dd>
129<dt>Recent Files</dt>
130<dd>Open a list of recent files. Click one to open it.</dd>
131<dt>Open Module...</dt>
132<dd>Open an existing module (searches sys.path).</dd>
133</dl>
134<dl class="docutils" id="index-1">
135<dt>Class Browser</dt>
136<dd>Show functions, classes, and methods in the current Editor file in a
137tree structure. In the shell, open a module first.</dd>
138<dt>Path Browser</dt>
139<dd>Show sys.path directories, modules, functions, classes and methods in a
140tree structure.</dd>
141<dt>Save</dt>
142<dd>Save the current window to the associated file, if there is one. Windows
143that have been changed since being opened or last saved have a * before
144and after the window title. If there is no associated file,
145do Save As instead.</dd>
146<dt>Save As...</dt>
147<dd>Save the current window with a Save As dialog. The file saved becomes the
148new associated file for the window.</dd>
149<dt>Save Copy As...</dt>
150<dd>Save the current window to different file without changing the associated
151file.</dd>
152<dt>Print Window</dt>
153<dd>Print the current window to the default printer.</dd>
154<dt>Close</dt>
155<dd>Close the current window (ask to save if unsaved).</dd>
156<dt>Exit</dt>
157<dd>Close all windows and quit IDLE (ask to save unsaved windows).</dd>
158</dl>
159</div>
160<div class="section" id="edit-menu-shell-and-editor">
161<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>
162<dl class="docutils">
163<dt>Undo</dt>
164<dd>Undo the last change to the current window. A maximum of 1000 changes may
165be undone.</dd>
166<dt>Redo</dt>
167<dd>Redo the last undone change to the current window.</dd>
168<dt>Cut</dt>
169<dd>Copy selection into the system-wide clipboard; then delete the selection.</dd>
170<dt>Copy</dt>
171<dd>Copy selection into the system-wide clipboard.</dd>
172<dt>Paste</dt>
173<dd>Insert contents of the system-wide clipboard into the current window.</dd>
174</dl>
175<p>The clipboard functions are also available in context menus.</p>
176<dl class="docutils">
177<dt>Select All</dt>
178<dd>Select the entire contents of the current window.</dd>
179<dt>Find...</dt>
180<dd>Open a search dialog with many options</dd>
181<dt>Find Again</dt>
182<dd>Repeat the last search, if there is one.</dd>
183<dt>Find Selection</dt>
184<dd>Search for the currently selected string, if there is one.</dd>
185<dt>Find in Files...</dt>
Terry Jan Reedy929d7f82016-05-02 18:30:02 -0400186<dd>Open a file search dialog. Put results in a new output window.</dd>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400187<dt>Replace...</dt>
188<dd>Open a search-and-replace dialog.</dd>
189<dt>Go to Line</dt>
190<dd>Move cursor to the line number requested and make that line visible.</dd>
191<dt>Show Completions</dt>
192<dd>Open a scrollable list allowing selection of keywords and attributes. See
193Completions in the Tips sections below.</dd>
194<dt>Expand Word</dt>
195<dd>Expand a prefix you have typed to match a full word in the same window;
196repeat to get a different expansion.</dd>
197<dt>Show call tip</dt>
198<dd>After an unclosed parenthesis for a function, open a small window with
199function parameter hints.</dd>
200<dt>Show surrounding parens</dt>
201<dd>Highlight the surrounding parenthesis.</dd>
202</dl>
203</div>
204<div class="section" id="format-menu-editor-window-only">
205<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>
206<dl class="docutils">
207<dt>Indent Region</dt>
208<dd>Shift selected lines right by the indent width (default 4 spaces).</dd>
209<dt>Dedent Region</dt>
210<dd>Shift selected lines left by the indent width (default 4 spaces).</dd>
211<dt>Comment Out Region</dt>
212<dd>Insert ## in front of selected lines.</dd>
213<dt>Uncomment Region</dt>
214<dd>Remove leading # or ## from selected lines.</dd>
215<dt>Tabify Region</dt>
216<dd>Turn <em>leading</em> stretches of spaces into tabs. (Note: We recommend using
2174 space blocks to indent Python code.)</dd>
218<dt>Untabify Region</dt>
219<dd>Turn <em>all</em> tabs into the correct number of spaces.</dd>
220<dt>Toggle Tabs</dt>
221<dd>Open a dialog to switch between indenting with spaces and tabs.</dd>
222<dt>New Indent Width</dt>
223<dd>Open a dialog to change indent width. The accepted default by the Python
224community is 4 spaces.</dd>
225<dt>Format Paragraph</dt>
226<dd>Reformat the current blank-line-delimited paragraph in comment block or
227multiline string or selected line in a string. All lines in the
228paragraph will be formatted to less than N columns, where N defaults to 72.</dd>
229<dt>Strip trailing whitespace</dt>
Terry Jan Reedyff702892017-09-15 13:05:28 -0400230<dd>Remove trailing space and other whitespace characters after the last
231non-whitespace character of a line by applying str.rstrip to each line,
232including lines within multiline strings.</dd>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400233</dl>
234</div>
235<div class="section" id="run-menu-editor-window-only">
236<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>
237<dl class="docutils">
238<dt>Python Shell</dt>
239<dd>Open or wake up the Python Shell window.</dd>
240<dt>Check Module</dt>
241<dd>Check the syntax of the module currently open in the Editor window. If the
242module has not been saved IDLE will either prompt the user to save or
243autosave, as selected in the General tab of the Idle Settings dialog. If
244there is a syntax error, the approximate location is indicated in the
245Editor window.</dd>
246<dt>Run Module</dt>
247<dd>Do Check Module (above). If no error, restart the shell to clean the
Terry Jan Reedy0053c472015-09-24 03:09:43 -0400248environment, then execute the module. Output is displayed in the Shell
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500249window. 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>.
Terry Jan Reedy0053c472015-09-24 03:09:43 -0400250When execution is complete, the Shell retains focus and displays a prompt.
251At this point, one may interactively explore the result of execution.
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500252This 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
Terry Jan Reedy0053c472015-09-24 03:09:43 -0400253line.</dd>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400254</dl>
255</div>
256<div class="section" id="shell-menu-shell-window-only">
257<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>
258<dl class="docutils">
259<dt>View Last Restart</dt>
260<dd>Scroll the shell window to the last Shell restart.</dd>
261<dt>Restart Shell</dt>
262<dd>Restart the shell to clean the environment.</dd>
Terry Jan Reedy4b736762016-09-12 01:50:03 -0400263<dt>Interrupt Execution</dt>
264<dd>Stop a running program.</dd>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400265</dl>
266</div>
267<div class="section" id="debug-menu-shell-window-only">
268<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>
269<dl class="docutils">
270<dt>Go to File/Line</dt>
271<dd>Look on the current line. with the cursor, and the line above for a filename
272and line number. If found, open the file if not already open, and show the
273line. Use this to view source lines referenced in an exception traceback
274and lines found by Find in Files. Also available in the context menu of
275the Shell window and Output windows.</dd>
276</dl>
277<dl class="docutils" id="index-3">
278<dt>Debugger (toggle)</dt>
terryjreedy188aedf2017-06-13 21:32:16 -0400279<dd>When activated, code entered in the Shell or run from an Editor will run
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400280under the debugger. In the Editor, breakpoints can be set with the context
281menu. This feature is still incomplete and somewhat experimental.</dd>
282<dt>Stack Viewer</dt>
283<dd>Show the stack traceback of the last exception in a tree widget, with
284access to locals and globals.</dd>
285<dt>Auto-open Stack Viewer</dt>
286<dd>Toggle automatically opening the stack viewer on an unhandled exception.</dd>
287</dl>
288</div>
289<div class="section" id="options-menu-shell-and-editor">
290<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>
291<dl class="docutils">
292<dt>Configure IDLE</dt>
Terry Jan Reedy93f35422015-10-13 22:03:51 -0400293<dd><p class="first">Open a configuration dialog and change preferences for the following:
294fonts, indentation, keybindings, text color themes, startup windows and
295size, additional help sources, and extensions (see below). On OS X,
296open the configuration dialog by selecting Preferences in the application
297menu. To use a new built-in color theme (IDLE Dark) with older IDLEs,
298save it as a new custom theme.</p>
299<p class="last">Non-default user settings are saved in a .idlerc directory in the user&#8217;s
300home directory. Problems caused by bad user configuration files are solved
301by editing or deleting one or more of the files in .idlerc.</p>
302</dd>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400303<dt>Code Context (toggle)(Editor Window only)</dt>
304<dd>Open a pane at the top of the edit window which shows the block context
305of the code which has scrolled above the top of the window.</dd>
306</dl>
307</div>
308<div class="section" id="window-menu-shell-and-editor">
309<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>
310<dl class="docutils">
311<dt>Zoom Height</dt>
312<dd>Toggles the window between normal size and maximum height. The initial size
313defaults to 40 lines by 80 chars unless changed on the General tab of the
314Configure IDLE dialog.</dd>
315</dl>
316<p>The rest of this menu lists the names of all open windows; select one to bring
317it to the foreground (deiconifying it if necessary).</p>
318</div>
319<div class="section" id="help-menu-shell-and-editor">
320<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>
321<dl class="docutils">
322<dt>About IDLE</dt>
323<dd>Display version, copyright, license, credits, and more.</dd>
324<dt>IDLE Help</dt>
325<dd>Display a help file for IDLE detailing the menu options, basic editing and
326navigation, and other tips.</dd>
327<dt>Python Docs</dt>
328<dd>Access local Python documentation, if installed, or start a web browser
329and open docs.python.org showing the latest Python documentation.</dd>
330<dt>Turtle Demo</dt>
331<dd>Run the turtledemo module with example python code and turtle drawings.</dd>
332</dl>
333<p>Additional help sources may be added here with the Configure IDLE dialog under
334the General tab.</p>
335</div>
336<div class="section" id="context-menus">
337<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>
338<p>Open a context menu by right-clicking in a window (Control-click on OS X).
339Context menus have the standard clipboard functions also on the Edit menu.</p>
340<dl class="docutils">
341<dt>Cut</dt>
342<dd>Copy selection into the system-wide clipboard; then delete the selection.</dd>
343<dt>Copy</dt>
344<dd>Copy selection into the system-wide clipboard.</dd>
345<dt>Paste</dt>
346<dd>Insert contents of the system-wide clipboard into the current window.</dd>
347</dl>
348<p>Editor windows also have breakpoint functions. Lines with a breakpoint set are
349specially marked. Breakpoints only have an effect when running under the
350debugger. Breakpoints for a file are saved in the user&#8217;s .idlerc directory.</p>
351<dl class="docutils">
352<dt>Set Breakpoint</dt>
353<dd>Set a breakpoint on the current line.</dd>
354<dt>Clear Breakpoint</dt>
355<dd>Clear the breakpoint on that line.</dd>
356</dl>
357<p>Shell and Output windows have the following.</p>
358<dl class="docutils">
359<dt>Go to file/line</dt>
360<dd>Same as in Debug menu.</dd>
361</dl>
362</div>
363</div>
364<div class="section" id="editing-and-navigation">
365<h2>25.5.2. Editing and navigation<a class="headerlink" href="#editing-and-navigation" title="Permalink to this headline"></a></h2>
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500366<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
367the <code class="kbd docutils literal"><span class="pre">Command</span></code> key on Mac OSX.</p>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400368<ul>
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500369<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>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400370</li>
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500371<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>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400372</li>
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500373<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>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400374</li>
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500375<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>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400376</li>
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500377<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>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400378</li>
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500379<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>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400380</li>
381<li><p class="first">Some useful Emacs bindings are inherited from Tcl/Tk:</p>
382<blockquote>
383<div><ul class="simple">
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500384<li><code class="kbd docutils literal"><span class="pre">C-a</span></code> beginning of line</li>
385<li><code class="kbd docutils literal"><span class="pre">C-e</span></code> end of line</li>
386<li><code class="kbd docutils literal"><span class="pre">C-k</span></code> kill line (but doesn&#8217;t put it in clipboard)</li>
387<li><code class="kbd docutils literal"><span class="pre">C-l</span></code> center window around the insertion point</li>
terryjreedy188aedf2017-06-13 21:32:16 -0400388<li><code class="kbd docutils literal"><span class="pre">C-b</span></code> go backward one character without deleting (usually you can
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400389also use the cursor key for this)</li>
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500390<li><code class="kbd docutils literal"><span class="pre">C-f</span></code> go forward one character without deleting (usually you can
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400391also use the cursor key for this)</li>
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500392<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
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400393this)</li>
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500394<li><code class="kbd docutils literal"><span class="pre">C-d</span></code> delete next character</li>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400395</ul>
396</div></blockquote>
397</li>
398</ul>
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500399<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)
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400400may work. Keybindings are selected in the Configure IDLE dialog.</p>
401<div class="section" id="automatic-indentation">
402<h3>25.5.2.1. Automatic indentation<a class="headerlink" href="#automatic-indentation" title="Permalink to this headline"></a></h3>
403<p>After a block-opening statement, the next line is indented by 4 spaces (in the
404Python Shell window by one tab). After certain keywords (break, return etc.)
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500405the next line is dedented. In leading indentation, <code class="kbd docutils literal"><span class="pre">Backspace</span></code> deletes up
406to 4 spaces if they are there. <code class="kbd docutils literal"><span class="pre">Tab</span></code> inserts spaces (in the Python
terryjreedy188aedf2017-06-13 21:32:16 -0400407Shell window one tab), number depends on Indent width. Currently, tabs
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400408are restricted to four spaces due to Tcl/Tk limitations.</p>
409<p>See also the indent/dedent region commands in the edit menu.</p>
410</div>
411<div class="section" id="completions">
412<h3>25.5.2.2. Completions<a class="headerlink" href="#completions" title="Permalink to this headline"></a></h3>
413<p>Completions are supplied for functions, classes, and attributes of classes,
414both built-in and user-defined. Completions are also provided for
415filenames.</p>
416<p>The AutoCompleteWindow (ACW) will open after a predefined delay (default is
417two seconds) after a &#8216;.&#8217; or (in a string) an os.sep is typed. If after one
418of those characters (plus zero or more other characters) a tab is typed
419the ACW will open immediately if a possible continuation is found.</p>
420<p>If there is only one possible completion for the characters entered, a
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500421<code class="kbd docutils literal"><span class="pre">Tab</span></code> will supply that completion without opening the ACW.</p>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400422<p>&#8216;Show Completions&#8217; will force open a completions window, by default the
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500423<code class="kbd docutils literal"><span class="pre">C-space</span></code> will open a completions window. In an empty
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400424string, this will contain the files in the current directory. On a
425blank line, it will contain the built-in and user-defined functions and
terryjreedy188aedf2017-06-13 21:32:16 -0400426classes in the current namespaces, plus any modules imported. If some
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400427characters have been entered, the ACW will attempt to be more specific.</p>
428<p>If a string of characters is typed, the ACW selection will jump to the
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500429entry most closely matching those characters. Entering a <code class="kbd docutils literal"><span class="pre">tab</span></code> will
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400430cause the longest non-ambiguous match to be entered in the Editor window or
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500431Shell. Two <code class="kbd docutils literal"><span class="pre">tab</span></code> in a row will supply the current ACW selection, as
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400432will return or a double click. Cursor keys, Page Up/Down, mouse selection,
433and the scroll wheel all operate on the ACW.</p>
434<p>&#8220;Hidden&#8221; attributes can be accessed by typing the beginning of hidden
435name after a &#8216;.&#8217;, e.g. &#8216;_&#8217;. This allows access to modules with
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500436<code class="docutils literal"><span class="pre">__all__</span></code> set, or to class-private attributes.</p>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400437<p>Completions and the &#8216;Expand Word&#8217; facility can save a lot of typing!</p>
438<p>Completions are currently limited to those in the namespaces. Names in
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500439an 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
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400440not be found. Run the module once with your imports to correct this situation.
441Note that IDLE itself places quite a few modules in sys.modules, so
442much can be found by default, e.g. the re module.</p>
443<p>If you don&#8217;t like the ACW popping up unbidden, simply make the delay
Terry Jan Reedy37f81352015-09-29 01:55:57 -0400444longer or disable the extension.</p>
445</div>
446<div class="section" id="calltips">
447<h3>25.5.2.3. Calltips<a class="headerlink" href="#calltips" title="Permalink to this headline"></a></h3>
terryjreedy188aedf2017-06-13 21:32:16 -0400448<p>A calltip is shown when one types <code class="kbd docutils literal"><span class="pre">(</span></code> after the name of an <em>accessible</em>
Terry Jan Reedy37f81352015-09-29 01:55:57 -0400449function. A name expression may include dots and subscripts. A calltip
450remains until it is clicked, the cursor is moved out of the argument area,
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500451or <code class="kbd docutils literal"><span class="pre">)</span></code> is typed. When the cursor is in the argument part of a definition,
Terry Jan Reedy37f81352015-09-29 01:55:57 -0400452the menu or shortcut display a calltip.</p>
453<p>A calltip consists of the function signature and the first line of the
454docstring. For builtins without an accessible signature, the calltip
455consists of all lines up the fifth line or the first blank line. These
456details may change.</p>
457<p>The set of <em>accessible</em> functions depends on what modules have been imported
458into the user process, including those imported by Idle itself,
459and what definitions have been run, all since the last restart.</p>
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500460<p>For example, restart the Shell and enter <code class="docutils literal"><span class="pre">itertools.count(</span></code>. A calltip
Terry Jan Reedy37f81352015-09-29 01:55:57 -0400461appears because Idle imports itertools into the user process for its own use.
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500462(This could change.) Enter <code class="docutils literal"><span class="pre">turtle.write(</span></code> and nothing appears. Idle does
Terry Jan Reedy37f81352015-09-29 01:55:57 -0400463not import turtle. The menu or shortcut do nothing either. Enter
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500464<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>
Terry Jan Reedy37f81352015-09-29 01:55:57 -0400465<p>In an editor, import statements have no effect until one runs the file. One
466might want to run a file after writing the import statements at the top,
467or immediately run an existing file before editing.</p>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400468</div>
469<div class="section" id="python-shell-window">
Terry Jan Reedy37f81352015-09-29 01:55:57 -0400470<h3>25.5.2.4. Python Shell window<a class="headerlink" href="#python-shell-window" title="Permalink to this headline"></a></h3>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400471<ul>
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500472<li><p class="first"><code class="kbd docutils literal"><span class="pre">C-c</span></code> interrupts executing command</p>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400473</li>
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500474<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>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400475</li>
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500476<li><p class="first"><code class="kbd docutils literal"><span class="pre">Alt-/</span></code> (Expand word) is also useful to reduce typing</p>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400477<p>Command history</p>
478<ul class="simple">
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500479<li><code class="kbd docutils literal"><span class="pre">Alt-p</span></code> retrieves previous command matching what you have typed. On
480OS X use <code class="kbd docutils literal"><span class="pre">C-p</span></code>.</li>
481<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>
482<li><code class="kbd docutils literal"><span class="pre">Return</span></code> while on any previous command retrieves that command</li>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400483</ul>
484</li>
485</ul>
486</div>
Terry Jan Reedyce021db2015-09-24 23:18:57 -0400487<div class="section" id="text-colors">
Terry Jan Reedy37f81352015-09-29 01:55:57 -0400488<h3>25.5.2.5. Text colors<a class="headerlink" href="#text-colors" title="Permalink to this headline"></a></h3>
Terry Jan Reedyce021db2015-09-24 23:18:57 -0400489<p>Idle defaults to black on white text, but colors text with special meanings.
490For the shell, these are shell output, shell error, user output, and
491user error. For Python code, at the shell prompt or in an editor, these are
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500492keywords, builtin class and function names, names following <code class="docutils literal"><span class="pre">class</span></code> and
493<code class="docutils literal"><span class="pre">def</span></code>, strings, and comments. For any text window, these are the cursor (when
Terry Jan Reedyce021db2015-09-24 23:18:57 -0400494present), found text (when possible), and selected text.</p>
495<p>Text coloring is done in the background, so uncolorized text is occasionally
496visible. To change the color scheme, use the Configure IDLE dialog
497Highlighting tab. The marking of debugger breakpoint lines in the editor and
498text in popups and dialogs is not user-configurable.</p>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400499</div>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400500</div>
Terry Jan Reedy0053c472015-09-24 03:09:43 -0400501<div class="section" id="startup-and-code-execution">
Terry Jan Reedyce021db2015-09-24 23:18:57 -0400502<h2>25.5.3. Startup and code execution<a class="headerlink" href="#startup-and-code-execution" title="Permalink to this headline"></a></h2>
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500503<p>Upon startup with the <code class="docutils literal"><span class="pre">-s</span></code> option, IDLE will execute the file referenced by
504the 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>.
505IDLE 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
506referenced is run. If <code class="docutils literal"><span class="pre">IDLESTARTUP</span></code> is not present, IDLE checks for
507<code class="docutils literal"><span class="pre">PYTHONSTARTUP</span></code>. Files referenced by these environment variables are
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400508convenient places to store functions that are used frequently from the IDLE
509shell, or for executing import statements to import common modules.</p>
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500510<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
511Tk file is loaded unconditionally. This additional file is <code class="docutils literal"><span class="pre">.Idle.py</span></code> and is
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400512looked for in the user&#8217;s home directory. Statements in this file will be
513executed in the Tk namespace, so this file is not useful for importing
514functions to be used from IDLE&#8217;s Python shell.</p>
515<div class="section" id="command-line-usage">
Terry Jan Reedyce021db2015-09-24 23:18:57 -0400516<h3>25.5.3.1. Command line usage<a class="headerlink" href="#command-line-usage" title="Permalink to this headline"></a></h3>
Terry Jan Reedy1f8cc332016-08-25 01:22:30 -0400517<div class="highlight-none"><div class="highlight"><pre><span></span>idle.py [-c command] [-d] [-e] [-h] [-i] [-r file] [-s] [-t title] [-] [arg] ...
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400518
Terry Jan Reedy968e2852015-09-23 03:52:23 -0400519-c command run command in the shell window
520-d enable debugger and open shell window
521-e open editor window
Terry Jan Reedy3399e1e2016-08-30 16:58:01 -0400522-h print help message with legal combinations and exit
Terry Jan Reedy968e2852015-09-23 03:52:23 -0400523-i open shell window
524-r file run file in shell window
525-s run $IDLESTARTUP or $PYTHONSTARTUP first, in shell window
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400526-t title set title of shell window
Terry Jan Reedy968e2852015-09-23 03:52:23 -0400527- run stdin in shell (- must be last option before args)
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400528</pre></div>
529</div>
530<p>If there are arguments:</p>
Terry Jan Reedy968e2852015-09-23 03:52:23 -0400531<ul class="simple">
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500532<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
533<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>,
534or <code class="docutils literal"><span class="pre">'-r'</span></code>. No editor window is opened, even if that is the default
Terry Jan Reedy968e2852015-09-23 03:52:23 -0400535set in the Options dialog.</li>
536<li>Otherwise, arguments are files opened for editing and
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500537<code class="docutils literal"><span class="pre">sys.argv</span></code> reflects the arguments passed to IDLE itself.</li>
Terry Jan Reedy968e2852015-09-23 03:52:23 -0400538</ul>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400539</div>
terryjreedy188aedf2017-06-13 21:32:16 -0400540<div class="section" id="startup-failure">
541<h3>25.5.3.2. Startup failure<a class="headerlink" href="#startup-failure" title="Permalink to this headline"></a></h3>
542<p>IDLE uses a socket to communicate between the IDLE GUI process and the user
543code execution process. A connection must be established whenever the Shell
544starts or restarts. (The latter is indicated by a divider line that says
545&#8216;RESTART&#8217;). If the user process fails to connect to the GUI process, it
546displays a <code class="docutils literal"><span class="pre">Tk</span></code> error box with a &#8216;cannot connect&#8217; message that directs the
547user here. It then exits.</p>
548<p>A common cause of failure is a user-written file with the same name as a
549standard library module, such as <em>random.py</em> and <em>tkinter.py</em>. When such a
550file is located in the same directory as a file that is about to be run,
551IDLE cannot import the stdlib file. The current fix is to rename the
552user file.</p>
553<p>Though less common than in the past, an antivirus or firewall program may
554stop the connection. If the program cannot be taught to allow the
555connection, then it must be turned off for IDLE to work. It is safe to
556allow this internal connection because no data is visible on external
557ports. A similar problem is a network mis-configuration that blocks
558connections.</p>
559<p>Python installation issues occasionally stop IDLE: multiple versions can
560clash, or a single installation might need admin access. If one undo the
561clash, or cannot or does not want to run as admin, it might be easiest to
562completely remove Python and start over.</p>
563<p>A zombie pythonw.exe process could be a problem. On Windows, use Task
564Manager to detect and stop one. Sometimes a restart initiated by a program
565crash or Keyboard Interrupt (control-C) may fail to connect. Dismissing
566the error box or Restart Shell on the Shell menu may fix a temporary problem.</p>
567<p>When IDLE first starts, it attempts to read user configuration files in
568~/.idlerc/ (~ is one&#8217;s home directory). If there is a problem, an error
569message should be displayed. Leaving aside random disk glitches, this can
570be prevented by never editing the files by hand, using the configuration
571dialog, under Options, instead Options. Once it happens, the solution may
572be to delete one or more of the configuration files.</p>
573<p>If IDLE quits with no message, and it was not started from a console, try
574starting from a console (<code class="docutils literal"><span class="pre">python</span> <span class="pre">-m</span> <span class="pre">idlelib)</span></code> and see if a message appears.</p>
575</div>
Terry Jan Reedy0053c472015-09-24 03:09:43 -0400576<div class="section" id="idle-console-differences">
terryjreedy188aedf2017-06-13 21:32:16 -0400577<h3>25.5.3.3. IDLE-console differences<a class="headerlink" href="#idle-console-differences" title="Permalink to this headline"></a></h3>
Terry Jan Reedy98758bc2017-09-12 09:05:16 -0400578<p>With rare exceptions, the result of executing Python code with IDLE is
579intended to be the same as executing the same code in a console window.
580However, the different interface and operation occasionally affect
581visible results. For instance, <code class="docutils literal"><span class="pre">sys.modules</span></code> starts with more entries.</p>
Terry Jan Reedy929d7f82016-05-02 18:30:02 -0400582<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
583objects that get input from and send output to the Shell window.
Terry Jan Reedy98758bc2017-09-12 09:05:16 -0400584When Shell has the focus, it controls the keyboard and screen. This is
585normally transparent, but functions that directly access the keyboard
Terry Jan Reedy929d7f82016-05-02 18:30:02 -0400586and 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>,
Terry Jan Reedy1f8cc332016-08-25 01:22:30 -0400587IDLE&#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
Terry Jan Reedy929d7f82016-05-02 18:30:02 -0400588<code class="docutils literal"><span class="pre">print</span></code> will not work correctly.</p>
Terry Jan Reedy0053c472015-09-24 03:09:43 -0400589<p>With IDLE&#8217;s Shell, one enters, edits, and recalls complete statements.
Terry Jan Reedy1f8cc332016-08-25 01:22:30 -0400590Some consoles only work with a single physical line at a time. IDLE uses
591<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
592defined for each statement.</p>
Terry Jan Reedy0053c472015-09-24 03:09:43 -0400593</div>
Terry Jan Reedy98758bc2017-09-12 09:05:16 -0400594<div class="section" id="developing-tkinter-applications">
595<h3>25.5.3.4. Developing tkinter applications<a class="headerlink" href="#developing-tkinter-applications" title="Permalink to this headline"></a></h3>
596<p>IDLE is intentionally different from standard Python in order to
597facilitate development of tkinter programs. Enter <code class="docutils literal"><span class="pre">import</span> <span class="pre">tkinter</span> <span class="pre">as</span> <span class="pre">tk;</span>
598<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
599in IDLE and a tk window appears. In standard Python, one must also enter
600<code class="docutils literal"><span class="pre">root.update()</span></code> to see the window. IDLE does the equivalent in the
601background, about 20 times a second, which is about every 50 milleseconds.
602Next enter <code class="docutils literal"><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,
603nothing visibly changes in standard Python until one enters <code class="docutils literal"><span class="pre">root.update()</span></code>.</p>
604<p>Most tkinter programs run <code class="docutils literal"><span class="pre">root.mainloop()</span></code>, which usually does not
605return until the tk app is destroyed. If the program is run with
606<code class="docutils literal"><span class="pre">python</span> <span class="pre">-i</span></code> or from an IDLE editor, a <code class="docutils literal"><span class="pre">&gt;&gt;&gt;</span></code> shell prompt does not
607appear until <code class="docutils literal"><span class="pre">mainloop()</span></code> returns, at which time there is nothing left
608to interact with.</p>
609<p>When running a tkinter program from an IDLE editor, one can comment out
610the mainloop call. One then gets a shell prompt immediately and can
611interact with the live application. One just has to remember to
612re-enable the mainloop call when running in standard Python.</p>
613</div>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400614<div class="section" id="running-without-a-subprocess">
Terry Jan Reedy98758bc2017-09-12 09:05:16 -0400615<h3>25.5.3.5. Running without a subprocess<a class="headerlink" href="#running-without-a-subprocess" title="Permalink to this headline"></a></h3>
Terry Jan Reedy0053c472015-09-24 03:09:43 -0400616<p>By default, IDLE executes user code in a separate subprocess via a socket,
Terry Jan Reedy6e10ec52015-09-23 20:00:33 -0400617which uses the internal loopback interface. This connection is not
618externally visible and no data is sent to or received from the Internet.
619If firewall software complains anyway, you can ignore it.</p>
620<p>If the attempt to make the socket connection fails, Idle will notify you.
621Such failures are sometimes transient, but if persistent, the problem
terryjreedy188aedf2017-06-13 21:32:16 -0400622may be either a firewall blocking the connection or misconfiguration of
Terry Jan Reedy6e10ec52015-09-23 20:00:33 -0400623a particular system. Until the problem is fixed, one can run Idle with
624the -n command line switch.</p>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400625<p>If IDLE is started with the -n command line switch it will run in a
626single process and will not create the subprocess which runs the RPC
627Python execution server. This can be useful if Python cannot create
628the subprocess or the RPC socket interface on your platform. However,
629in this mode user code is not isolated from IDLE itself. Also, the
630environment is not restarted when Run/Run Module (F5) is selected. If
631your code has been modified, you must reload() the affected modules and
632re-import any specific items (e.g. from foo import baz) if the changes
633are to take effect. For these reasons, it is preferable to run IDLE
634with the default subprocess if at all possible.</p>
635<div class="deprecated">
636<p><span class="versionmodified">Deprecated since version 3.4.</span></p>
637</div>
638</div>
639</div>
640<div class="section" id="help-and-preferences">
Terry Jan Reedyce021db2015-09-24 23:18:57 -0400641<h2>25.5.4. Help and preferences<a class="headerlink" href="#help-and-preferences" title="Permalink to this headline"></a></h2>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400642<div class="section" id="additional-help-sources">
Terry Jan Reedyce021db2015-09-24 23:18:57 -0400643<h3>25.5.4.1. Additional help sources<a class="headerlink" href="#additional-help-sources" title="Permalink to this headline"></a></h3>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400644<p>IDLE includes a help menu entry called &#8220;Python Docs&#8221; that will open the
645extensive sources of help, including tutorials, available at docs.python.org.
646Selected URLs can be added or removed from the help menu at any time using the
647Configure IDLE dialog. See the IDLE help option in the help menu of IDLE for
648more information.</p>
649</div>
650<div class="section" id="setting-preferences">
Terry Jan Reedyce021db2015-09-24 23:18:57 -0400651<h3>25.5.4.2. Setting preferences<a class="headerlink" href="#setting-preferences" title="Permalink to this headline"></a></h3>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400652<p>The font preferences, highlighting, keys, and general preferences can be
653changed via Configure IDLE on the Option menu. Keys can be user defined;
terryjreedy188aedf2017-06-13 21:32:16 -0400654IDLE ships with four built-in key sets. In addition, a user can create a
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400655custom key set in the Configure IDLE dialog under the keys tab.</p>
656</div>
657<div class="section" id="extensions">
Terry Jan Reedyce021db2015-09-24 23:18:57 -0400658<h3>25.5.4.3. Extensions<a class="headerlink" href="#extensions" title="Permalink to this headline"></a></h3>
terryjreedy188aedf2017-06-13 21:32:16 -0400659<p>IDLE contains an extension facility. Preferences for extensions can be
Terry Jan Reedyadb4cd22017-09-12 07:45:15 -0400660changed with the Extensions tab of the preferences dialog. See the
661beginning of config-extensions.def in the idlelib directory for further
662information. The only current default extension is zzdummy, an example
Terry Jan Reedy98758bc2017-09-12 09:05:16 -0400663also used for testing.</p>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400664</div>
665</div>
666</div>
667
668
669 </div>
670 </div>
671 </div>
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500672 <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400673 <div class="sphinxsidebarwrapper">
674 <h3><a href="../contents.html">Table Of Contents</a></h3>
675 <ul>
676<li><a class="reference internal" href="#">25.5. IDLE</a><ul>
677<li><a class="reference internal" href="#menus">25.5.1. Menus</a><ul>
678<li><a class="reference internal" href="#file-menu-shell-and-editor">25.5.1.1. File menu (Shell and Editor)</a></li>
679<li><a class="reference internal" href="#edit-menu-shell-and-editor">25.5.1.2. Edit menu (Shell and Editor)</a></li>
680<li><a class="reference internal" href="#format-menu-editor-window-only">25.5.1.3. Format menu (Editor window only)</a></li>
681<li><a class="reference internal" href="#run-menu-editor-window-only">25.5.1.4. Run menu (Editor window only)</a></li>
682<li><a class="reference internal" href="#shell-menu-shell-window-only">25.5.1.5. Shell menu (Shell window only)</a></li>
683<li><a class="reference internal" href="#debug-menu-shell-window-only">25.5.1.6. Debug menu (Shell window only)</a></li>
684<li><a class="reference internal" href="#options-menu-shell-and-editor">25.5.1.7. Options menu (Shell and Editor)</a></li>
685<li><a class="reference internal" href="#window-menu-shell-and-editor">25.5.1.8. Window menu (Shell and Editor)</a></li>
686<li><a class="reference internal" href="#help-menu-shell-and-editor">25.5.1.9. Help menu (Shell and Editor)</a></li>
687<li><a class="reference internal" href="#context-menus">25.5.1.10. Context Menus</a></li>
688</ul>
689</li>
690<li><a class="reference internal" href="#editing-and-navigation">25.5.2. Editing and navigation</a><ul>
691<li><a class="reference internal" href="#automatic-indentation">25.5.2.1. Automatic indentation</a></li>
692<li><a class="reference internal" href="#completions">25.5.2.2. Completions</a></li>
Terry Jan Reedy37f81352015-09-29 01:55:57 -0400693<li><a class="reference internal" href="#calltips">25.5.2.3. Calltips</a></li>
694<li><a class="reference internal" href="#python-shell-window">25.5.2.4. Python Shell window</a></li>
695<li><a class="reference internal" href="#text-colors">25.5.2.5. Text colors</a></li>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400696</ul>
697</li>
Terry Jan Reedyce021db2015-09-24 23:18:57 -0400698<li><a class="reference internal" href="#startup-and-code-execution">25.5.3. Startup and code execution</a><ul>
699<li><a class="reference internal" href="#command-line-usage">25.5.3.1. Command line usage</a></li>
terryjreedy188aedf2017-06-13 21:32:16 -0400700<li><a class="reference internal" href="#startup-failure">25.5.3.2. Startup failure</a></li>
701<li><a class="reference internal" href="#idle-console-differences">25.5.3.3. IDLE-console differences</a></li>
Terry Jan Reedy98758bc2017-09-12 09:05:16 -0400702<li><a class="reference internal" href="#developing-tkinter-applications">25.5.3.4. Developing tkinter applications</a></li>
703<li><a class="reference internal" href="#running-without-a-subprocess">25.5.3.5. Running without a subprocess</a></li>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400704</ul>
705</li>
Terry Jan Reedyce021db2015-09-24 23:18:57 -0400706<li><a class="reference internal" href="#help-and-preferences">25.5.4. Help and preferences</a><ul>
707<li><a class="reference internal" href="#additional-help-sources">25.5.4.1. Additional help sources</a></li>
708<li><a class="reference internal" href="#setting-preferences">25.5.4.2. Setting preferences</a></li>
709<li><a class="reference internal" href="#extensions">25.5.4.3. Extensions</a></li>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400710</ul>
711</li>
712</ul>
713</li>
714</ul>
715
716 <h4>Previous topic</h4>
717 <p class="topless"><a href="tkinter.scrolledtext.html"
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500718 title="previous chapter">25.4. <code class="docutils literal"><span class="pre">tkinter.scrolledtext</span></code> &#8212; Scrolled Text Widget</a></p>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400719 <h4>Next topic</h4>
720 <p class="topless"><a href="othergui.html"
721 title="next chapter">25.6. Other Graphical User Interface Packages</a></p>
Terry Jan Reedy4b736762016-09-12 01:50:03 -0400722 <div role="note" aria-label="source link">
723 <h3>This Page</h3>
724 <ul class="this-page-menu">
725 <li><a href="../bugs.html">Report a Bug</a></li>
terryjreedy188aedf2017-06-13 21:32:16 -0400726 <li>
Terry Jan Reedyadb4cd22017-09-12 07:45:15 -0400727 <a href="https://github.com/python/cpython/blob/master/Doc/library/idle.txt"
terryjreedy188aedf2017-06-13 21:32:16 -0400728 rel="nofollow">Show Source
729 </a>
730 </li>
Terry Jan Reedy4b736762016-09-12 01:50:03 -0400731 </ul>
732 </div>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400733 </div>
734 </div>
735 <div class="clearer"></div>
Terry Jan Reedy963a38b2015-09-20 20:03:01 -0400736 </div>
Terry Jan Reedyf8cd02d2016-03-01 00:29:57 -0500737 <div class="related" role="navigation" aria-label="related navigation">
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400738 <h3>Navigation</h3>
739 <ul>
740 <li class="right" style="margin-right: 10px">
741 <a href="../genindex.html" title="General Index"
742 >index</a></li>
743 <li class="right" >
744 <a href="../py-modindex.html" title="Python Module Index"
745 >modules</a> |</li>
746 <li class="right" >
747 <a href="othergui.html" title="25.6. Other Graphical User Interface Packages"
748 >next</a> |</li>
749 <li class="right" >
750 <a href="tkinter.scrolledtext.html" title="25.4. tkinter.scrolledtext — Scrolled Text Widget"
751 >previous</a> |</li>
752 <li><img src="../_static/py.png" alt=""
753 style="vertical-align: middle; margin-top: -1px"/></li>
Terry Jan Reedy3399e1e2016-08-30 16:58:01 -0400754 <li><a href="https://www.python.org/">Python</a> &raquo;</li>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400755 <li>
terryjreedy188aedf2017-06-13 21:32:16 -0400756 <a href="../index.html">3.7.0a0 Documentation</a> &raquo;
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400757 </li>
758
Terry Jan Reedy3399e1e2016-08-30 16:58:01 -0400759 <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &raquo;</li>
760 <li class="nav-item nav-item-2"><a href="tk.html" >25. Graphical User Interfaces with Tk</a> &raquo;</li>
Terry Jan Reedy4b736762016-09-12 01:50:03 -0400761 <li class="right">
762
763
764 <div class="inline-search" style="display: none" role="search">
765 <form class="inline-search" action="../search.html" method="get">
766 <input placeholder="Quick search" type="text" name="q" />
767 <input type="submit" value="Go" />
768 <input type="hidden" name="check_keywords" value="yes" />
769 <input type="hidden" name="area" value="default" />
770 </form>
771 </div>
772 <script type="text/javascript">$('.inline-search').show(0);</script>
773 |
774 </li>
775
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400776 </ul>
Terry Jan Reedy963a38b2015-09-20 20:03:01 -0400777 </div>
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400778 <div class="footer">
terryjreedy188aedf2017-06-13 21:32:16 -0400779 &copy; <a href="../copyright.html">Copyright</a> 2001-2017, Python Software Foundation.
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400780 <br />
781 The Python Software Foundation is a non-profit corporation.
782 <a href="https://www.python.org/psf/donations/">Please donate.</a>
783 <br />
Terry Jan Reedyff702892017-09-15 13:05:28 -0400784 Last updated on Sep 15, 2017.
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400785 <a href="../bugs.html">Found a bug</a>?
786 <br />
Terry Jan Reedy3399e1e2016-08-30 16:58:01 -0400787 Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.3.6.
Terry Jan Reedy5d46ab12015-09-20 19:57:13 -0400788 </div>
789
790 </body>
Terry Jan Reedy963a38b2015-09-20 20:03:01 -0400791</html>