Terry Jan Reedy | a2f257b | 2015-09-20 19:56:54 -0400 | [diff] [blame] | 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" /> |
Terry Jan Reedy | 72895c1 | 2015-09-20 20:02:23 -0400 | [diff] [blame^] | 8 | |
Terry Jan Reedy | a2f257b | 2015-09-20 19:56:54 -0400 | [diff] [blame] | 9 | <title>24.6. IDLE — Python 2.7.10 documentation</title> |
Terry Jan Reedy | 72895c1 | 2015-09-20 20:02:23 -0400 | [diff] [blame^] | 10 | |
Terry Jan Reedy | a2f257b | 2015-09-20 19:56:54 -0400 | [diff] [blame] | 11 | <link rel="stylesheet" href="../_static/default.css" type="text/css" /> |
| 12 | <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> |
Terry Jan Reedy | 72895c1 | 2015-09-20 20:02:23 -0400 | [diff] [blame^] | 13 | |
Terry Jan Reedy | a2f257b | 2015-09-20 19:56:54 -0400 | [diff] [blame] | 14 | <script type="text/javascript"> |
| 15 | var DOCUMENTATION_OPTIONS = { |
| 16 | URL_ROOT: '../', |
| 17 | VERSION: '2.7.10', |
| 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 2.7.10 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 2.7.10 documentation" href="../index.html" /> |
| 33 | <link rel="up" title="24. Graphical User Interfaces with Tk" href="tk.html" /> |
| 34 | <link rel="next" title="24.7. Other Graphical User Interface Packages" href="othergui.html" /> |
| 35 | <link rel="prev" title="24.5. turtle — Turtle graphics for Tk" href="turtle.html" /> |
| 36 | <link rel="shortcut icon" type="image/png" href="../_static/py.png" /> |
| 37 | <script type="text/javascript" src="../_static/copybutton.js"></script> |
Terry Jan Reedy | 72895c1 | 2015-09-20 20:02:23 -0400 | [diff] [blame^] | 38 | |
| 39 | |
| 40 | |
Terry Jan Reedy | a2f257b | 2015-09-20 19:56:54 -0400 | [diff] [blame] | 41 | |
| 42 | </head> |
Terry Jan Reedy | 72895c1 | 2015-09-20 20:02:23 -0400 | [diff] [blame^] | 43 | <body> |
Terry Jan Reedy | a2f257b | 2015-09-20 19:56:54 -0400 | [diff] [blame] | 44 | <div class="related"> |
| 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="24.7. Other Graphical User Interface Packages" |
| 55 | accesskey="N">next</a> |</li> |
| 56 | <li class="right" > |
| 57 | <a href="turtle.html" title="24.5. turtle — Turtle graphics for Tk" |
| 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> »</li> |
| 62 | <li> |
| 63 | <a href="../index.html">Python 2.7.10 documentation</a> » |
| 64 | </li> |
| 65 | |
| 66 | <li><a href="index.html" >The Python Standard Library</a> »</li> |
Terry Jan Reedy | 72895c1 | 2015-09-20 20:02:23 -0400 | [diff] [blame^] | 67 | <li><a href="tk.html" accesskey="U">24. Graphical User Interfaces with Tk</a> »</li> |
Terry Jan Reedy | a2f257b | 2015-09-20 19:56:54 -0400 | [diff] [blame] | 68 | </ul> |
Terry Jan Reedy | 72895c1 | 2015-09-20 20:02:23 -0400 | [diff] [blame^] | 69 | </div> |
Terry Jan Reedy | a2f257b | 2015-09-20 19:56:54 -0400 | [diff] [blame] | 70 | |
| 71 | <div class="document"> |
| 72 | <div class="documentwrapper"> |
| 73 | <div class="bodywrapper"> |
| 74 | <div class="body"> |
Terry Jan Reedy | 72895c1 | 2015-09-20 20:02:23 -0400 | [diff] [blame^] | 75 | |
Terry Jan Reedy | a2f257b | 2015-09-20 19:56:54 -0400 | [diff] [blame] | 76 | <div class="section" id="idle"> |
| 77 | <span id="id1"></span><h1>24.6. IDLE<a class="headerlink" href="#idle" title="Permalink to this headline">¶</a></h1> |
| 78 | <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> |
| 79 | <p>IDLE has the following features:</p> |
| 80 | <ul class="simple"> |
| 81 | <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> |
| 82 | <li>cross-platform: works on Windows, Unix, and Mac OS X</li> |
| 83 | <li>multi-window text editor with multiple undo, Python colorizing, |
| 84 | smart indent, call tips, and many other features</li> |
| 85 | <li>Python shell window (a.k.a. interactive interpreter)</li> |
| 86 | <li>debugger (not complete, but you can set breakpoints, view and step)</li> |
| 87 | </ul> |
| 88 | <div class="section" id="menus"> |
| 89 | <h2>24.6.1. Menus<a class="headerlink" href="#menus" title="Permalink to this headline">¶</a></h2> |
| 90 | <p>IDLE has two main window types, the Shell window and the Editor window. It is |
| 91 | possible to have multiple editor windows simultaneously. Output windows, such |
| 92 | as used for Edit / Find in Files, are a subtype of edit window. They currently |
| 93 | have the same top menu as Editor windows but a different default title and |
| 94 | context menu.</p> |
| 95 | <p>IDLE’s menus dynamically change based on which window is currently selected. |
| 96 | Each menu documented below indicates which window type it is associated with.</p> |
| 97 | <div class="section" id="file-menu-shell-and-editor"> |
| 98 | <h3>24.6.1.1. File menu (Shell and Editor)<a class="headerlink" href="#file-menu-shell-and-editor" title="Permalink to this headline">¶</a></h3> |
| 99 | <dl class="docutils"> |
| 100 | <dt>New File</dt> |
| 101 | <dd>Create a new file editing window.</dd> |
| 102 | <dt>Open...</dt> |
| 103 | <dd>Open an existing file with an Open dialog.</dd> |
| 104 | <dt>Recent Files</dt> |
| 105 | <dd>Open a list of recent files. Click one to open it.</dd> |
| 106 | <dt>Open Module...</dt> |
| 107 | <dd>Open an existing module (searches sys.path).</dd> |
| 108 | </dl> |
| 109 | <dl class="docutils" id="index-1"> |
| 110 | <dt>Class Browser</dt> |
| 111 | <dd>Show functions, classes, and methods in the current Editor file in a |
| 112 | tree structure. In the shell, open a module first.</dd> |
| 113 | <dt>Path Browser</dt> |
| 114 | <dd>Show sys.path directories, modules, functions, classes and methods in a |
| 115 | tree structure.</dd> |
| 116 | <dt>Save</dt> |
| 117 | <dd>Save the current window to the associated file, if there is one. Windows |
| 118 | that have been changed since being opened or last saved have a * before |
| 119 | and after the window title. If there is no associated file, |
| 120 | do Save As instead.</dd> |
| 121 | <dt>Save As...</dt> |
| 122 | <dd>Save the current window with a Save As dialog. The file saved becomes the |
| 123 | new associated file for the window.</dd> |
| 124 | <dt>Save Copy As...</dt> |
| 125 | <dd>Save the current window to different file without changing the associated |
| 126 | file.</dd> |
| 127 | <dt>Print Window</dt> |
| 128 | <dd>Print the current window to the default printer.</dd> |
| 129 | <dt>Close</dt> |
| 130 | <dd>Close the current window (ask to save if unsaved).</dd> |
| 131 | <dt>Exit</dt> |
| 132 | <dd>Close all windows and quit IDLE (ask to save unsaved windows).</dd> |
| 133 | </dl> |
| 134 | </div> |
| 135 | <div class="section" id="edit-menu-shell-and-editor"> |
| 136 | <h3>24.6.1.2. Edit menu (Shell and Editor)<a class="headerlink" href="#edit-menu-shell-and-editor" title="Permalink to this headline">¶</a></h3> |
| 137 | <dl class="docutils"> |
| 138 | <dt>Undo</dt> |
| 139 | <dd>Undo the last change to the current window. A maximum of 1000 changes may |
| 140 | be undone.</dd> |
| 141 | <dt>Redo</dt> |
| 142 | <dd>Redo the last undone change to the current window.</dd> |
| 143 | <dt>Cut</dt> |
| 144 | <dd>Copy selection into the system-wide clipboard; then delete the selection.</dd> |
| 145 | <dt>Copy</dt> |
| 146 | <dd>Copy selection into the system-wide clipboard.</dd> |
| 147 | <dt>Paste</dt> |
| 148 | <dd>Insert contents of the system-wide clipboard into the current window.</dd> |
| 149 | </dl> |
| 150 | <p>The clipboard functions are also available in context menus.</p> |
| 151 | <dl class="docutils"> |
| 152 | <dt>Select All</dt> |
| 153 | <dd>Select the entire contents of the current window.</dd> |
| 154 | <dt>Find...</dt> |
| 155 | <dd>Open a search dialog with many options</dd> |
| 156 | <dt>Find Again</dt> |
| 157 | <dd>Repeat the last search, if there is one.</dd> |
| 158 | <dt>Find Selection</dt> |
| 159 | <dd>Search for the currently selected string, if there is one.</dd> |
| 160 | <dt>Find in Files...</dt> |
| 161 | <dd>Open a file search dialog. Put results in an new output window.</dd> |
| 162 | <dt>Replace...</dt> |
| 163 | <dd>Open a search-and-replace dialog.</dd> |
| 164 | <dt>Go to Line</dt> |
| 165 | <dd>Move cursor to the line number requested and make that line visible.</dd> |
| 166 | <dt>Show Completions</dt> |
| 167 | <dd>Open a scrollable list allowing selection of keywords and attributes. See |
| 168 | Completions in the Tips sections below.</dd> |
| 169 | <dt>Expand Word</dt> |
| 170 | <dd>Expand a prefix you have typed to match a full word in the same window; |
| 171 | repeat to get a different expansion.</dd> |
| 172 | <dt>Show call tip</dt> |
| 173 | <dd>After an unclosed parenthesis for a function, open a small window with |
| 174 | function parameter hints.</dd> |
| 175 | <dt>Show surrounding parens</dt> |
| 176 | <dd>Highlight the surrounding parenthesis.</dd> |
| 177 | </dl> |
| 178 | </div> |
| 179 | <div class="section" id="format-menu-editor-window-only"> |
| 180 | <h3>24.6.1.3. Format menu (Editor window only)<a class="headerlink" href="#format-menu-editor-window-only" title="Permalink to this headline">¶</a></h3> |
| 181 | <dl class="docutils"> |
| 182 | <dt>Indent Region</dt> |
| 183 | <dd>Shift selected lines right by the indent width (default 4 spaces).</dd> |
| 184 | <dt>Dedent Region</dt> |
| 185 | <dd>Shift selected lines left by the indent width (default 4 spaces).</dd> |
| 186 | <dt>Comment Out Region</dt> |
| 187 | <dd>Insert ## in front of selected lines.</dd> |
| 188 | <dt>Uncomment Region</dt> |
| 189 | <dd>Remove leading # or ## from selected lines.</dd> |
| 190 | <dt>Tabify Region</dt> |
| 191 | <dd>Turn <em>leading</em> stretches of spaces into tabs. (Note: We recommend using |
| 192 | 4 space blocks to indent Python code.)</dd> |
| 193 | <dt>Untabify Region</dt> |
| 194 | <dd>Turn <em>all</em> tabs into the correct number of spaces.</dd> |
| 195 | <dt>Toggle Tabs</dt> |
| 196 | <dd>Open a dialog to switch between indenting with spaces and tabs.</dd> |
| 197 | <dt>New Indent Width</dt> |
| 198 | <dd>Open a dialog to change indent width. The accepted default by the Python |
| 199 | community is 4 spaces.</dd> |
| 200 | <dt>Format Paragraph</dt> |
| 201 | <dd>Reformat the current blank-line-delimited paragraph in comment block or |
| 202 | multiline string or selected line in a string. All lines in the |
| 203 | paragraph will be formatted to less than N columns, where N defaults to 72.</dd> |
| 204 | <dt>Strip trailing whitespace</dt> |
| 205 | <dd>Remove any space characters after the last non-space character of a line.</dd> |
| 206 | </dl> |
| 207 | </div> |
| 208 | <div class="section" id="run-menu-editor-window-only"> |
| 209 | <span id="index-2"></span><h3>24.6.1.4. Run menu (Editor window only)<a class="headerlink" href="#run-menu-editor-window-only" title="Permalink to this headline">¶</a></h3> |
| 210 | <dl class="docutils"> |
| 211 | <dt>Python Shell</dt> |
| 212 | <dd>Open or wake up the Python Shell window.</dd> |
| 213 | <dt>Check Module</dt> |
| 214 | <dd>Check the syntax of the module currently open in the Editor window. If the |
| 215 | module has not been saved IDLE will either prompt the user to save or |
| 216 | autosave, as selected in the General tab of the Idle Settings dialog. If |
| 217 | there is a syntax error, the approximate location is indicated in the |
| 218 | Editor window.</dd> |
| 219 | <dt>Run Module</dt> |
| 220 | <dd>Do Check Module (above). If no error, restart the shell to clean the |
| 221 | environment, then execute the module.</dd> |
| 222 | </dl> |
| 223 | </div> |
| 224 | <div class="section" id="shell-menu-shell-window-only"> |
| 225 | <h3>24.6.1.5. Shell menu (Shell window only)<a class="headerlink" href="#shell-menu-shell-window-only" title="Permalink to this headline">¶</a></h3> |
| 226 | <dl class="docutils"> |
| 227 | <dt>View Last Restart</dt> |
| 228 | <dd>Scroll the shell window to the last Shell restart.</dd> |
| 229 | <dt>Restart Shell</dt> |
| 230 | <dd>Restart the shell to clean the environment.</dd> |
| 231 | </dl> |
| 232 | </div> |
| 233 | <div class="section" id="debug-menu-shell-window-only"> |
| 234 | <h3>24.6.1.6. Debug menu (Shell window only)<a class="headerlink" href="#debug-menu-shell-window-only" title="Permalink to this headline">¶</a></h3> |
| 235 | <dl class="docutils"> |
| 236 | <dt>Go to File/Line</dt> |
| 237 | <dd>Look on the current line. with the cursor, and the line above for a filename |
| 238 | and line number. If found, open the file if not already open, and show the |
| 239 | line. Use this to view source lines referenced in an exception traceback |
| 240 | and lines found by Find in Files. Also available in the context menu of |
| 241 | the Shell window and Output windows.</dd> |
| 242 | </dl> |
| 243 | <dl class="docutils" id="index-3"> |
| 244 | <dt>Debugger (toggle)</dt> |
| 245 | <dd>When actived, code entered in the Shell or run from an Editor will run |
| 246 | under the debugger. In the Editor, breakpoints can be set with the context |
| 247 | menu. This feature is still incomplete and somewhat experimental.</dd> |
| 248 | <dt>Stack Viewer</dt> |
| 249 | <dd>Show the stack traceback of the last exception in a tree widget, with |
| 250 | access to locals and globals.</dd> |
| 251 | <dt>Auto-open Stack Viewer</dt> |
| 252 | <dd>Toggle automatically opening the stack viewer on an unhandled exception.</dd> |
| 253 | </dl> |
| 254 | </div> |
| 255 | <div class="section" id="options-menu-shell-and-editor"> |
| 256 | <h3>24.6.1.7. Options menu (Shell and Editor)<a class="headerlink" href="#options-menu-shell-and-editor" title="Permalink to this headline">¶</a></h3> |
| 257 | <dl class="docutils"> |
| 258 | <dt>Configure IDLE</dt> |
| 259 | <dd>Open a configuration dialog. Fonts, indentation, keybindings, and color |
| 260 | themes may be altered. Startup Preferences may be set, and additional |
| 261 | help sources can be specified. Non-default user setting are saved in a |
| 262 | .idlerc directory in the user’s home directory. Problems caused by bad user |
| 263 | configuration files are solved by editing or deleting one or more of the |
| 264 | files in .idlerc. On OS X, open the configuration dialog by selecting |
| 265 | Preferences in the application menu.</dd> |
| 266 | <dt>Configure Extensions</dt> |
| 267 | <dd>Open a configuration dialog for setting preferences for extensions |
| 268 | (discussed below). See note above about the location of user settings.</dd> |
| 269 | <dt>Code Context (toggle)(Editor Window only)</dt> |
| 270 | <dd>Open a pane at the top of the edit window which shows the block context |
| 271 | of the code which has scrolled above the top of the window.</dd> |
| 272 | </dl> |
| 273 | </div> |
| 274 | <div class="section" id="window-menu-shell-and-editor"> |
| 275 | <h3>24.6.1.8. Window menu (Shell and Editor)<a class="headerlink" href="#window-menu-shell-and-editor" title="Permalink to this headline">¶</a></h3> |
| 276 | <dl class="docutils"> |
| 277 | <dt>Zoom Height</dt> |
| 278 | <dd>Toggles the window between normal size and maximum height. The initial size |
| 279 | defaults to 40 lines by 80 chars unless changed on the General tab of the |
| 280 | Configure IDLE dialog.</dd> |
| 281 | </dl> |
| 282 | <p>The rest of this menu lists the names of all open windows; select one to bring |
| 283 | it to the foreground (deiconifying it if necessary).</p> |
| 284 | </div> |
| 285 | <div class="section" id="help-menu-shell-and-editor"> |
| 286 | <h3>24.6.1.9. Help menu (Shell and Editor)<a class="headerlink" href="#help-menu-shell-and-editor" title="Permalink to this headline">¶</a></h3> |
| 287 | <dl class="docutils"> |
| 288 | <dt>About IDLE</dt> |
| 289 | <dd>Display version, copyright, license, credits, and more.</dd> |
| 290 | <dt>IDLE Help</dt> |
| 291 | <dd>Display a help file for IDLE detailing the menu options, basic editing and |
| 292 | navigation, and other tips.</dd> |
| 293 | <dt>Python Docs</dt> |
| 294 | <dd>Access local Python documentation, if installed, or start a web browser |
| 295 | and open docs.python.org showing the latest Python documentation.</dd> |
| 296 | <dt>Turtle Demo</dt> |
| 297 | <dd>Run the turtledemo module with example python code and turtle drawings.</dd> |
| 298 | </dl> |
| 299 | <p>Additional help sources may be added here with the Configure IDLE dialog under |
| 300 | the General tab.</p> |
| 301 | </div> |
| 302 | <div class="section" id="context-menus"> |
| 303 | <span id="index-4"></span><h3>24.6.1.10. Context Menus<a class="headerlink" href="#context-menus" title="Permalink to this headline">¶</a></h3> |
| 304 | <p>Open a context menu by right-clicking in a window (Control-click on OS X). |
| 305 | Context menus have the standard clipboard functions also on the Edit menu.</p> |
| 306 | <dl class="docutils"> |
| 307 | <dt>Cut</dt> |
| 308 | <dd>Copy selection into the system-wide clipboard; then delete the selection.</dd> |
| 309 | <dt>Copy</dt> |
| 310 | <dd>Copy selection into the system-wide clipboard.</dd> |
| 311 | <dt>Paste</dt> |
| 312 | <dd>Insert contents of the system-wide clipboard into the current window.</dd> |
| 313 | </dl> |
| 314 | <p>Editor windows also have breakpoint functions. Lines with a breakpoint set are |
| 315 | specially marked. Breakpoints only have an effect when running under the |
| 316 | debugger. Breakpoints for a file are saved in the user’s .idlerc directory.</p> |
| 317 | <dl class="docutils"> |
| 318 | <dt>Set Breakpoint</dt> |
| 319 | <dd>Set a breakpoint on the current line.</dd> |
| 320 | <dt>Clear Breakpoint</dt> |
| 321 | <dd>Clear the breakpoint on that line.</dd> |
| 322 | </dl> |
| 323 | <p>Shell and Output windows have the following.</p> |
| 324 | <dl class="docutils"> |
| 325 | <dt>Go to file/line</dt> |
| 326 | <dd>Same as in Debug menu.</dd> |
| 327 | </dl> |
| 328 | </div> |
| 329 | </div> |
| 330 | <div class="section" id="editing-and-navigation"> |
| 331 | <h2>24.6.2. Editing and navigation<a class="headerlink" href="#editing-and-navigation" title="Permalink to this headline">¶</a></h2> |
| 332 | <p>In this section, ‘C’ refers to the <tt class="kbd docutils literal"><span class="pre">Control</span></tt> key on Windows and Unix and |
| 333 | the <tt class="kbd docutils literal"><span class="pre">Command</span></tt> key on Mac OSX.</p> |
| 334 | <ul> |
| 335 | <li><p class="first"><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</p> |
| 336 | </li> |
| 337 | <li><p class="first"><tt class="kbd docutils literal"><span class="pre">C-Backspace</span></tt> delete word left; <tt class="kbd docutils literal"><span class="pre">C-Del</span></tt> delete word to the right</p> |
| 338 | </li> |
| 339 | <li><p class="first">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</p> |
| 340 | </li> |
| 341 | <li><p class="first"><tt class="kbd docutils literal"><span class="pre">C-LeftArrow</span></tt> and <tt class="kbd docutils literal"><span class="pre">C-RightArrow</span></tt> moves by words</p> |
| 342 | </li> |
| 343 | <li><p class="first"><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</p> |
| 344 | </li> |
| 345 | <li><p class="first"><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</p> |
| 346 | </li> |
| 347 | <li><p class="first">Some useful Emacs bindings are inherited from Tcl/Tk:</p> |
| 348 | <blockquote> |
| 349 | <div><ul class="simple"> |
| 350 | <li><tt class="kbd docutils literal"><span class="pre">C-a</span></tt> beginning of line</li> |
| 351 | <li><tt class="kbd docutils literal"><span class="pre">C-e</span></tt> end of line</li> |
| 352 | <li><tt class="kbd docutils literal"><span class="pre">C-k</span></tt> kill line (but doesn’t put it in clipboard)</li> |
| 353 | <li><tt class="kbd docutils literal"><span class="pre">C-l</span></tt> center window around the insertion point</li> |
| 354 | <li><tt class="kbd docutils literal"><span class="pre">C-b</span></tt> go backwards one character without deleting (usually you can |
| 355 | also use the cursor key for this)</li> |
| 356 | <li><tt class="kbd docutils literal"><span class="pre">C-f</span></tt> go forward one character without deleting (usually you can |
| 357 | also use the cursor key for this)</li> |
| 358 | <li><tt class="kbd docutils literal"><span class="pre">C-p</span></tt> go up one line (usually you can also use the cursor key for |
| 359 | this)</li> |
| 360 | <li><tt class="kbd docutils literal"><span class="pre">C-d</span></tt> delete next character</li> |
| 361 | </ul> |
| 362 | </div></blockquote> |
| 363 | </li> |
| 364 | </ul> |
| 365 | <p>Standard keybindings (like <tt class="kbd docutils literal"><span class="pre">C-c</span></tt> to copy and <tt class="kbd docutils literal"><span class="pre">C-v</span></tt> to paste) |
| 366 | may work. Keybindings are selected in the Configure IDLE dialog.</p> |
| 367 | <div class="section" id="automatic-indentation"> |
| 368 | <h3>24.6.2.1. Automatic indentation<a class="headerlink" href="#automatic-indentation" title="Permalink to this headline">¶</a></h3> |
| 369 | <p>After a block-opening statement, the next line is indented by 4 spaces (in the |
| 370 | Python Shell window by one tab). After certain keywords (break, return etc.) |
| 371 | the next line is dedented. In leading indentation, <tt class="kbd docutils literal"><span class="pre">Backspace</span></tt> deletes up |
| 372 | to 4 spaces if they are there. <tt class="kbd docutils literal"><span class="pre">Tab</span></tt> inserts spaces (in the Python |
| 373 | Shell window one tab), number depends on Indent width. Currently tabs |
| 374 | are restricted to four spaces due to Tcl/Tk limitations.</p> |
| 375 | <p>See also the indent/dedent region commands in the edit menu.</p> |
| 376 | </div> |
| 377 | <div class="section" id="completions"> |
| 378 | <h3>24.6.2.2. Completions<a class="headerlink" href="#completions" title="Permalink to this headline">¶</a></h3> |
| 379 | <p>Completions are supplied for functions, classes, and attributes of classes, |
| 380 | both built-in and user-defined. Completions are also provided for |
| 381 | filenames.</p> |
| 382 | <p>The AutoCompleteWindow (ACW) will open after a predefined delay (default is |
| 383 | two seconds) after a ‘.’ or (in a string) an os.sep is typed. If after one |
| 384 | of those characters (plus zero or more other characters) a tab is typed |
| 385 | the ACW will open immediately if a possible continuation is found.</p> |
| 386 | <p>If there is only one possible completion for the characters entered, a |
| 387 | <tt class="kbd docutils literal"><span class="pre">Tab</span></tt> will supply that completion without opening the ACW.</p> |
| 388 | <p>‘Show Completions’ will force open a completions window, by default the |
| 389 | <tt class="kbd docutils literal"><span class="pre">C-space</span></tt> will open a completions window. In an empty |
| 390 | string, this will contain the files in the current directory. On a |
| 391 | blank line, it will contain the built-in and user-defined functions and |
| 392 | classes in the current name spaces, plus any modules imported. If some |
| 393 | characters have been entered, the ACW will attempt to be more specific.</p> |
| 394 | <p>If a string of characters is typed, the ACW selection will jump to the |
| 395 | entry most closely matching those characters. Entering a <tt class="kbd docutils literal"><span class="pre">tab</span></tt> will |
| 396 | cause the longest non-ambiguous match to be entered in the Editor window or |
| 397 | Shell. Two <tt class="kbd docutils literal"><span class="pre">tab</span></tt> in a row will supply the current ACW selection, as |
| 398 | will return or a double click. Cursor keys, Page Up/Down, mouse selection, |
| 399 | and the scroll wheel all operate on the ACW.</p> |
| 400 | <p>“Hidden” attributes can be accessed by typing the beginning of hidden |
| 401 | name after a ‘.’, e.g. ‘_’. This allows access to modules with |
| 402 | <tt class="docutils literal"><span class="pre">__all__</span></tt> set, or to class-private attributes.</p> |
| 403 | <p>Completions and the ‘Expand Word’ facility can save a lot of typing!</p> |
| 404 | <p>Completions are currently limited to those in the namespaces. Names in |
| 405 | an Editor window which are not via <tt class="docutils literal"><span class="pre">__main__</span></tt> and <a class="reference internal" href="sys.html#sys.modules" title="sys.modules"><tt class="xref py py-data docutils literal"><span class="pre">sys.modules</span></tt></a> will |
| 406 | not be found. Run the module once with your imports to correct this situation. |
| 407 | Note that IDLE itself places quite a few modules in sys.modules, so |
| 408 | much can be found by default, e.g. the re module.</p> |
| 409 | <p>If you don’t like the ACW popping up unbidden, simply make the delay |
| 410 | longer or disable the extension. Or another option is the delay could |
| 411 | be set to zero. Another alternative to preventing ACW popups is to |
| 412 | disable the call tips extension.</p> |
| 413 | </div> |
| 414 | <div class="section" id="python-shell-window"> |
| 415 | <h3>24.6.2.3. Python Shell window<a class="headerlink" href="#python-shell-window" title="Permalink to this headline">¶</a></h3> |
| 416 | <ul> |
| 417 | <li><p class="first"><tt class="kbd docutils literal"><span class="pre">C-c</span></tt> interrupts executing command</p> |
| 418 | </li> |
| 419 | <li><p class="first"><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</p> |
| 420 | </li> |
| 421 | <li><p class="first"><tt class="kbd docutils literal"><span class="pre">Alt-/</span></tt> (Expand word) is also useful to reduce typing</p> |
| 422 | <p>Command history</p> |
| 423 | <ul class="simple"> |
| 424 | <li><tt class="kbd docutils literal"><span class="pre">Alt-p</span></tt> retrieves previous command matching what you have typed. On |
| 425 | OS X use <tt class="kbd docutils literal"><span class="pre">C-p</span></tt>.</li> |
| 426 | <li><tt class="kbd docutils literal"><span class="pre">Alt-n</span></tt> retrieves next. On OS X use <tt class="kbd docutils literal"><span class="pre">C-n</span></tt>.</li> |
| 427 | <li><tt class="kbd docutils literal"><span class="pre">Return</span></tt> while on any previous command retrieves that command</li> |
| 428 | </ul> |
| 429 | </li> |
| 430 | </ul> |
| 431 | </div> |
| 432 | </div> |
| 433 | <div class="section" id="syntax-colors"> |
| 434 | <h2>24.6.3. Syntax colors<a class="headerlink" href="#syntax-colors" title="Permalink to this headline">¶</a></h2> |
| 435 | <p>The coloring is applied in a background “thread,” so you may occasionally see |
| 436 | uncolorized text. To change the color scheme, edit the <tt class="docutils literal"><span class="pre">[Colors]</span></tt> section in |
| 437 | <tt class="file docutils literal"><span class="pre">config.txt</span></tt>.</p> |
| 438 | <dl class="docutils"> |
| 439 | <dt>Python syntax colors:</dt> |
| 440 | <dd><dl class="first last docutils"> |
| 441 | <dt>Keywords</dt> |
| 442 | <dd>orange</dd> |
| 443 | <dt>Strings</dt> |
| 444 | <dd>green</dd> |
| 445 | <dt>Comments</dt> |
| 446 | <dd>red</dd> |
| 447 | <dt>Definitions</dt> |
| 448 | <dd>blue</dd> |
| 449 | </dl> |
| 450 | </dd> |
| 451 | <dt>Shell colors:</dt> |
| 452 | <dd><dl class="first last docutils"> |
| 453 | <dt>Console output</dt> |
| 454 | <dd>brown</dd> |
| 455 | <dt>stdout</dt> |
| 456 | <dd>blue</dd> |
| 457 | <dt>stderr</dt> |
| 458 | <dd>dark green</dd> |
| 459 | <dt>stdin</dt> |
| 460 | <dd>black</dd> |
| 461 | </dl> |
| 462 | </dd> |
| 463 | </dl> |
| 464 | </div> |
| 465 | <div class="section" id="startup"> |
| 466 | <h2>24.6.4. Startup<a class="headerlink" href="#startup" title="Permalink to this headline">¶</a></h2> |
| 467 | <p>Upon startup with the <tt class="docutils literal"><span class="pre">-s</span></tt> option, IDLE will execute the file referenced by |
| 468 | the environment variables <span class="target" id="index-5"></span><tt class="xref std std-envvar docutils literal"><span class="pre">IDLESTARTUP</span></tt> or <span class="target" id="index-6"></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>. |
| 469 | 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 |
| 470 | referenced is run. If <tt class="docutils literal"><span class="pre">IDLESTARTUP</span></tt> is not present, IDLE checks for |
| 471 | <tt class="docutils literal"><span class="pre">PYTHONSTARTUP</span></tt>. Files referenced by these environment variables are |
| 472 | convenient places to store functions that are used frequently from the IDLE |
| 473 | shell, or for executing import statements to import common modules.</p> |
| 474 | <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 |
| 475 | Tk file is loaded unconditionally. This additional file is <tt class="docutils literal"><span class="pre">.Idle.py</span></tt> and is |
| 476 | looked for in the user’s home directory. Statements in this file will be |
| 477 | executed in the Tk namespace, so this file is not useful for importing |
| 478 | functions to be used from IDLE’s Python shell.</p> |
| 479 | <div class="section" id="command-line-usage"> |
| 480 | <h3>24.6.4.1. Command line usage<a class="headerlink" href="#command-line-usage" title="Permalink to this headline">¶</a></h3> |
| 481 | <div class="highlight-python"><div class="highlight"><pre>idle.py [-c command] [-d] [-e] [-s] [-t title] [arg] ... |
| 482 | |
| 483 | -c command run this command |
| 484 | -d enable debugger |
| 485 | -e edit mode; arguments are files to be edited |
| 486 | -s run $IDLESTARTUP or $PYTHONSTARTUP first |
| 487 | -t title set title of shell window |
| 488 | </pre></div> |
| 489 | </div> |
| 490 | <p>If there are arguments:</p> |
| 491 | <ol class="arabic simple"> |
| 492 | <li>If <tt class="docutils literal"><span class="pre">-e</span></tt> is used, arguments are files opened for editing and |
| 493 | <tt class="docutils literal"><span class="pre">sys.argv</span></tt> reflects the arguments passed to IDLE itself.</li> |
| 494 | <li>Otherwise, if <tt class="docutils literal"><span class="pre">-c</span></tt> is used, all arguments are placed in |
| 495 | <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> |
| 496 | <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 |
| 497 | argument is a script which is executed with the remaining arguments in |
| 498 | <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 |
| 499 | script name is ‘-‘, no script is executed but an interactive Python session |
| 500 | is started; the arguments are still available in <tt class="docutils literal"><span class="pre">sys.argv</span></tt>.</li> |
| 501 | </ol> |
| 502 | </div> |
| 503 | <div class="section" id="running-without-a-subprocess"> |
| 504 | <h3>24.6.4.2. Running without a subprocess<a class="headerlink" href="#running-without-a-subprocess" title="Permalink to this headline">¶</a></h3> |
| 505 | <p>If IDLE is started with the -n command line switch it will run in a |
| 506 | single process and will not create the subprocess which runs the RPC |
| 507 | Python execution server. This can be useful if Python cannot create |
| 508 | the subprocess or the RPC socket interface on your platform. However, |
| 509 | in this mode user code is not isolated from IDLE itself. Also, the |
| 510 | environment is not restarted when Run/Run Module (F5) is selected. If |
| 511 | your code has been modified, you must reload() the affected modules and |
| 512 | re-import any specific items (e.g. from foo import baz) if the changes |
| 513 | are to take effect. For these reasons, it is preferable to run IDLE |
| 514 | with the default subprocess if at all possible.</p> |
| 515 | <div class="deprecated"> |
| 516 | <p><span class="versionmodified">Deprecated since version 3.4.</span></p> |
| 517 | </div> |
| 518 | </div> |
| 519 | </div> |
| 520 | <div class="section" id="help-and-preferences"> |
| 521 | <h2>24.6.5. Help and preferences<a class="headerlink" href="#help-and-preferences" title="Permalink to this headline">¶</a></h2> |
| 522 | <div class="section" id="additional-help-sources"> |
| 523 | <h3>24.6.5.1. Additional help sources<a class="headerlink" href="#additional-help-sources" title="Permalink to this headline">¶</a></h3> |
| 524 | <p>IDLE includes a help menu entry called “Python Docs” that will open the |
| 525 | extensive sources of help, including tutorials, available at docs.python.org. |
| 526 | Selected URLs can be added or removed from the help menu at any time using the |
| 527 | Configure IDLE dialog. See the IDLE help option in the help menu of IDLE for |
| 528 | more information.</p> |
| 529 | </div> |
| 530 | <div class="section" id="setting-preferences"> |
| 531 | <h3>24.6.5.2. Setting preferences<a class="headerlink" href="#setting-preferences" title="Permalink to this headline">¶</a></h3> |
| 532 | <p>The font preferences, highlighting, keys, and general preferences can be |
| 533 | changed via Configure IDLE on the Option menu. Keys can be user defined; |
| 534 | IDLE ships with four built in key sets. In addition a user can create a |
| 535 | custom key set in the Configure IDLE dialog under the keys tab.</p> |
| 536 | </div> |
| 537 | <div class="section" id="extensions"> |
| 538 | <h3>24.6.5.3. Extensions<a class="headerlink" href="#extensions" title="Permalink to this headline">¶</a></h3> |
| 539 | <p>IDLE contains an extension facility. Peferences for extensions can be |
| 540 | changed with Configure Extensions. See the beginning of config-extensions.def |
| 541 | in the idlelib directory for further information. The default extensions |
| 542 | are currently:</p> |
| 543 | <ul class="simple"> |
| 544 | <li>FormatParagraph</li> |
| 545 | <li>AutoExpand</li> |
| 546 | <li>ZoomHeight</li> |
| 547 | <li>ScriptBinding</li> |
| 548 | <li>CallTips</li> |
| 549 | <li>ParenMatch</li> |
| 550 | <li>AutoComplete</li> |
| 551 | <li>CodeContext</li> |
| 552 | <li>RstripExtension</li> |
| 553 | </ul> |
| 554 | </div> |
| 555 | </div> |
| 556 | </div> |
| 557 | |
| 558 | |
| 559 | </div> |
| 560 | </div> |
| 561 | </div> |
| 562 | <div class="sphinxsidebar"> |
| 563 | <div class="sphinxsidebarwrapper"> |
| 564 | <h3><a href="../contents.html">Table Of Contents</a></h3> |
| 565 | <ul> |
| 566 | <li><a class="reference internal" href="#">24.6. IDLE</a><ul> |
| 567 | <li><a class="reference internal" href="#menus">24.6.1. Menus</a><ul> |
| 568 | <li><a class="reference internal" href="#file-menu-shell-and-editor">24.6.1.1. File menu (Shell and Editor)</a></li> |
| 569 | <li><a class="reference internal" href="#edit-menu-shell-and-editor">24.6.1.2. Edit menu (Shell and Editor)</a></li> |
| 570 | <li><a class="reference internal" href="#format-menu-editor-window-only">24.6.1.3. Format menu (Editor window only)</a></li> |
| 571 | <li><a class="reference internal" href="#run-menu-editor-window-only">24.6.1.4. Run menu (Editor window only)</a></li> |
| 572 | <li><a class="reference internal" href="#shell-menu-shell-window-only">24.6.1.5. Shell menu (Shell window only)</a></li> |
| 573 | <li><a class="reference internal" href="#debug-menu-shell-window-only">24.6.1.6. Debug menu (Shell window only)</a></li> |
| 574 | <li><a class="reference internal" href="#options-menu-shell-and-editor">24.6.1.7. Options menu (Shell and Editor)</a></li> |
| 575 | <li><a class="reference internal" href="#window-menu-shell-and-editor">24.6.1.8. Window menu (Shell and Editor)</a></li> |
| 576 | <li><a class="reference internal" href="#help-menu-shell-and-editor">24.6.1.9. Help menu (Shell and Editor)</a></li> |
| 577 | <li><a class="reference internal" href="#context-menus">24.6.1.10. Context Menus</a></li> |
| 578 | </ul> |
| 579 | </li> |
| 580 | <li><a class="reference internal" href="#editing-and-navigation">24.6.2. Editing and navigation</a><ul> |
| 581 | <li><a class="reference internal" href="#automatic-indentation">24.6.2.1. Automatic indentation</a></li> |
| 582 | <li><a class="reference internal" href="#completions">24.6.2.2. Completions</a></li> |
| 583 | <li><a class="reference internal" href="#python-shell-window">24.6.2.3. Python Shell window</a></li> |
| 584 | </ul> |
| 585 | </li> |
| 586 | <li><a class="reference internal" href="#syntax-colors">24.6.3. Syntax colors</a></li> |
| 587 | <li><a class="reference internal" href="#startup">24.6.4. Startup</a><ul> |
| 588 | <li><a class="reference internal" href="#command-line-usage">24.6.4.1. Command line usage</a></li> |
| 589 | <li><a class="reference internal" href="#running-without-a-subprocess">24.6.4.2. Running without a subprocess</a></li> |
| 590 | </ul> |
| 591 | </li> |
| 592 | <li><a class="reference internal" href="#help-and-preferences">24.6.5. Help and preferences</a><ul> |
| 593 | <li><a class="reference internal" href="#additional-help-sources">24.6.5.1. Additional help sources</a></li> |
| 594 | <li><a class="reference internal" href="#setting-preferences">24.6.5.2. Setting preferences</a></li> |
| 595 | <li><a class="reference internal" href="#extensions">24.6.5.3. Extensions</a></li> |
| 596 | </ul> |
| 597 | </li> |
| 598 | </ul> |
| 599 | </li> |
| 600 | </ul> |
| 601 | |
| 602 | <h4>Previous topic</h4> |
| 603 | <p class="topless"><a href="turtle.html" |
| 604 | title="previous chapter">24.5. <tt class="docutils literal"><span class="pre">turtle</span></tt> — Turtle graphics for Tk</a></p> |
| 605 | <h4>Next topic</h4> |
| 606 | <p class="topless"><a href="othergui.html" |
| 607 | title="next chapter">24.7. Other Graphical User Interface Packages</a></p> |
| 608 | <h3>This Page</h3> |
| 609 | <ul class="this-page-menu"> |
| 610 | <li><a href="../bugs.html">Report a Bug</a></li> |
| 611 | <li><a href="../_sources/library/idle.txt" |
| 612 | rel="nofollow">Show Source</a></li> |
| 613 | </ul> |
| 614 | |
| 615 | <div id="searchbox" style="display: none"> |
| 616 | <h3>Quick search</h3> |
| 617 | <form class="search" action="../search.html" method="get"> |
| 618 | <input type="text" name="q" /> |
| 619 | <input type="submit" value="Go" /> |
| 620 | <input type="hidden" name="check_keywords" value="yes" /> |
| 621 | <input type="hidden" name="area" value="default" /> |
| 622 | </form> |
| 623 | <p class="searchtip" style="font-size: 90%"> |
| 624 | Enter search terms or a module, class or function name. |
| 625 | </p> |
| 626 | </div> |
| 627 | <script type="text/javascript">$('#searchbox').show(0);</script> |
| 628 | </div> |
| 629 | </div> |
| 630 | <div class="clearer"></div> |
Terry Jan Reedy | 72895c1 | 2015-09-20 20:02:23 -0400 | [diff] [blame^] | 631 | </div> |
Terry Jan Reedy | a2f257b | 2015-09-20 19:56:54 -0400 | [diff] [blame] | 632 | <div class="related"> |
| 633 | <h3>Navigation</h3> |
| 634 | <ul> |
| 635 | <li class="right" style="margin-right: 10px"> |
| 636 | <a href="../genindex.html" title="General Index" |
| 637 | >index</a></li> |
| 638 | <li class="right" > |
| 639 | <a href="../py-modindex.html" title="Python Module Index" |
| 640 | >modules</a> |</li> |
| 641 | <li class="right" > |
| 642 | <a href="othergui.html" title="24.7. Other Graphical User Interface Packages" |
| 643 | >next</a> |</li> |
| 644 | <li class="right" > |
| 645 | <a href="turtle.html" title="24.5. turtle — Turtle graphics for Tk" |
| 646 | >previous</a> |</li> |
| 647 | <li><img src="../_static/py.png" alt="" |
| 648 | style="vertical-align: middle; margin-top: -1px"/></li> |
| 649 | <li><a href="https://www.python.org/">Python</a> »</li> |
| 650 | <li> |
| 651 | <a href="../index.html">Python 2.7.10 documentation</a> » |
| 652 | </li> |
| 653 | |
| 654 | <li><a href="index.html" >The Python Standard Library</a> »</li> |
Terry Jan Reedy | 72895c1 | 2015-09-20 20:02:23 -0400 | [diff] [blame^] | 655 | <li><a href="tk.html" >24. Graphical User Interfaces with Tk</a> »</li> |
Terry Jan Reedy | a2f257b | 2015-09-20 19:56:54 -0400 | [diff] [blame] | 656 | </ul> |
Terry Jan Reedy | 72895c1 | 2015-09-20 20:02:23 -0400 | [diff] [blame^] | 657 | </div> |
Terry Jan Reedy | a2f257b | 2015-09-20 19:56:54 -0400 | [diff] [blame] | 658 | <div class="footer"> |
| 659 | © <a href="../copyright.html">Copyright</a> 1990-2015, Python Software Foundation. |
| 660 | <br /> |
| 661 | The Python Software Foundation is a non-profit corporation. |
| 662 | <a href="https://www.python.org/psf/donations/">Please donate.</a> |
| 663 | <br /> |
| 664 | Last updated on Sep 20, 2015. |
| 665 | <a href="../bugs.html">Found a bug</a>? |
| 666 | <br /> |
| 667 | Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.2.3. |
| 668 | </div> |
| 669 | |
| 670 | </body> |
Terry Jan Reedy | 72895c1 | 2015-09-20 20:02:23 -0400 | [diff] [blame^] | 671 | </html> |