gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1212 lines
78KB

  1. <!DOCTYPE html>
  2. <html lang="en" data-content_root="../">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
  6. <meta property="og:title" content="IDLE" />
  7. <meta property="og:type" content="website" />
  8. <meta property="og:url" content="https://docs.python.org/3/library/idle.html" />
  9. <meta property="og:site_name" content="Python documentation" />
  10. <meta property="og:description" content="Source code: Lib/idlelib/ IDLE is Python’s Integrated Development and Learning Environment. IDLE has the following features: cross-platform: works mostly the same on Windows, Unix, and macOS, Pytho..." />
  11. <meta property="og:image" content="https://docs.python.org/3/_static/og-image.png" />
  12. <meta property="og:image:alt" content="Python documentation" />
  13. <meta name="description" content="Source code: Lib/idlelib/ IDLE is Python’s Integrated Development and Learning Environment. IDLE has the following features: cross-platform: works mostly the same on Windows, Unix, and macOS, Pytho..." />
  14. <meta property="og:image:width" content="200" />
  15. <meta property="og:image:height" content="200" />
  16. <meta name="theme-color" content="#3776ab" />
  17. <title>IDLE &#8212; Python 3.12.3 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
  18. <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=80d5e7a1" />
  19. <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=bb723527" />
  20. <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=b20cc3f5" />
  21. <script src="../_static/documentation_options.js?v=2c828074"></script>
  22. <script src="../_static/doctools.js?v=888ff710"></script>
  23. <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
  24. <script src="../_static/sidebar.js"></script>
  25. <link rel="search" type="application/opensearchdescription+xml"
  26. title="Search within Python 3.12.3 documentation"
  27. href="../_static/opensearch.xml"/>
  28. <link rel="author" title="About these documents" href="../about.html" />
  29. <link rel="index" title="Index" href="../genindex.html" />
  30. <link rel="search" title="Search" href="../search.html" />
  31. <link rel="copyright" title="Copyright" href="../copyright.html" />
  32. <link rel="next" title="Development Tools" href="development.html" />
  33. <link rel="prev" title="tkinter.tix — Extension widgets for Tk" href="tkinter.tix.html" />
  34. <link rel="canonical" href="https://docs.python.org/3/library/idle.html" />
  35. <style>
  36. @media only screen {
  37. table.full-width-table {
  38. width: 100%;
  39. }
  40. }
  41. </style>
  42. <link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
  43. <link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
  44. <script type="text/javascript" src="../_static/copybutton.js"></script>
  45. <script type="text/javascript" src="../_static/menu.js"></script>
  46. <script type="text/javascript" src="../_static/search-focus.js"></script>
  47. <script type="text/javascript" src="../_static/themetoggle.js"></script>
  48. </head>
  49. <body>
  50. <div class="mobile-nav">
  51. <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
  52. aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
  53. <nav class="nav-content" role="navigation">
  54. <label for="menuToggler" class="toggler__label">
  55. <span></span>
  56. </label>
  57. <span class="nav-items-wrapper">
  58. <a href="https://www.python.org/" class="nav-logo">
  59. <img src="../_static/py.svg" alt="Python logo"/>
  60. </a>
  61. <span class="version_switcher_placeholder"></span>
  62. <form role="search" class="search" action="../search.html" method="get">
  63. <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
  64. <path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>
  65. </svg>
  66. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
  67. <input type="submit" value="Go"/>
  68. </form>
  69. </span>
  70. </nav>
  71. <div class="menu-wrapper">
  72. <nav class="menu" role="navigation" aria-label="main navigation">
  73. <div class="language_switcher_placeholder"></div>
  74. <label class="theme-selector-label">
  75. Theme
  76. <select class="theme-selector" oninput="activateTheme(this.value)">
  77. <option value="auto" selected>Auto</option>
  78. <option value="light">Light</option>
  79. <option value="dark">Dark</option>
  80. </select>
  81. </label>
  82. <div>
  83. <h3><a href="../contents.html">Table of Contents</a></h3>
  84. <ul>
  85. <li><a class="reference internal" href="#">IDLE</a><ul>
  86. <li><a class="reference internal" href="#menus">Menus</a><ul>
  87. <li><a class="reference internal" href="#file-menu-shell-and-editor">File menu (Shell and Editor)</a></li>
  88. <li><a class="reference internal" href="#edit-menu-shell-and-editor">Edit menu (Shell and Editor)</a></li>
  89. <li><a class="reference internal" href="#format-menu-editor-window-only">Format menu (Editor window only)</a></li>
  90. <li><a class="reference internal" href="#run-menu-editor-window-only">Run menu (Editor window only)</a></li>
  91. <li><a class="reference internal" href="#shell-menu-shell-window-only">Shell menu (Shell window only)</a></li>
  92. <li><a class="reference internal" href="#debug-menu-shell-window-only">Debug menu (Shell window only)</a></li>
  93. <li><a class="reference internal" href="#options-menu-shell-and-editor">Options menu (Shell and Editor)</a></li>
  94. <li><a class="reference internal" href="#window-menu-shell-and-editor">Window menu (Shell and Editor)</a></li>
  95. <li><a class="reference internal" href="#help-menu-shell-and-editor">Help menu (Shell and Editor)</a></li>
  96. <li><a class="reference internal" href="#context-menus">Context menus</a></li>
  97. </ul>
  98. </li>
  99. <li><a class="reference internal" href="#editing-and-navigation">Editing and Navigation</a><ul>
  100. <li><a class="reference internal" href="#editor-windows">Editor windows</a></li>
  101. <li><a class="reference internal" href="#key-bindings">Key bindings</a></li>
  102. <li><a class="reference internal" href="#automatic-indentation">Automatic indentation</a></li>
  103. <li><a class="reference internal" href="#search-and-replace">Search and Replace</a></li>
  104. <li><a class="reference internal" href="#completions">Completions</a></li>
  105. <li><a class="reference internal" href="#calltips">Calltips</a></li>
  106. <li><a class="reference internal" href="#code-context">Code Context</a></li>
  107. <li><a class="reference internal" href="#shell-window">Shell window</a></li>
  108. <li><a class="reference internal" href="#text-colors">Text colors</a></li>
  109. </ul>
  110. </li>
  111. <li><a class="reference internal" href="#startup-and-code-execution">Startup and Code Execution</a><ul>
  112. <li><a class="reference internal" href="#command-line-usage">Command line usage</a></li>
  113. <li><a class="reference internal" href="#startup-failure">Startup failure</a></li>
  114. <li><a class="reference internal" href="#running-user-code">Running user code</a></li>
  115. <li><a class="reference internal" href="#user-output-in-shell">User output in Shell</a></li>
  116. <li><a class="reference internal" href="#developing-tkinter-applications">Developing tkinter applications</a></li>
  117. <li><a class="reference internal" href="#running-without-a-subprocess">Running without a subprocess</a></li>
  118. </ul>
  119. </li>
  120. <li><a class="reference internal" href="#help-and-preferences">Help and Preferences</a><ul>
  121. <li><a class="reference internal" href="#help-sources">Help sources</a></li>
  122. <li><a class="reference internal" href="#setting-preferences">Setting preferences</a></li>
  123. <li><a class="reference internal" href="#idle-on-macos">IDLE on macOS</a></li>
  124. <li><a class="reference internal" href="#extensions">Extensions</a></li>
  125. </ul>
  126. </li>
  127. <li><a class="reference internal" href="#module-idlelib">idlelib</a></li>
  128. </ul>
  129. </li>
  130. </ul>
  131. </div>
  132. <div>
  133. <h4>Previous topic</h4>
  134. <p class="topless"><a href="tkinter.tix.html"
  135. title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.tix</span></code> — Extension widgets for Tk</a></p>
  136. </div>
  137. <div>
  138. <h4>Next topic</h4>
  139. <p class="topless"><a href="development.html"
  140. title="next chapter">Development Tools</a></p>
  141. </div>
  142. <div role="note" aria-label="source link">
  143. <h3>This Page</h3>
  144. <ul class="this-page-menu">
  145. <li><a href="../bugs.html">Report a Bug</a></li>
  146. <li>
  147. <a href="https://github.com/python/cpython/blob/main/Doc/library/idle.rst"
  148. rel="nofollow">Show Source
  149. </a>
  150. </li>
  151. </ul>
  152. </div>
  153. </nav>
  154. </div>
  155. </div>
  156. <div class="related" role="navigation" aria-label="related navigation">
  157. <h3>Navigation</h3>
  158. <ul>
  159. <li class="right" style="margin-right: 10px">
  160. <a href="../genindex.html" title="General Index"
  161. accesskey="I">index</a></li>
  162. <li class="right" >
  163. <a href="../py-modindex.html" title="Python Module Index"
  164. >modules</a> |</li>
  165. <li class="right" >
  166. <a href="development.html" title="Development Tools"
  167. accesskey="N">next</a> |</li>
  168. <li class="right" >
  169. <a href="tkinter.tix.html" title="tkinter.tix — Extension widgets for Tk"
  170. accesskey="P">previous</a> |</li>
  171. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  172. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  173. <li class="switchers">
  174. <div class="language_switcher_placeholder"></div>
  175. <div class="version_switcher_placeholder"></div>
  176. </li>
  177. <li>
  178. </li>
  179. <li id="cpython-language-and-version">
  180. <a href="../index.html">3.12.3 Documentation</a> &#187;
  181. </li>
  182. <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
  183. <li class="nav-item nav-item-2"><a href="tk.html" accesskey="U">Graphical User Interfaces with Tk</a> &#187;</li>
  184. <li class="nav-item nav-item-this"><a href="">IDLE</a></li>
  185. <li class="right">
  186. <div class="inline-search" role="search">
  187. <form class="inline-search" action="../search.html" method="get">
  188. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  189. <input type="submit" value="Go" />
  190. </form>
  191. </div>
  192. |
  193. </li>
  194. <li class="right">
  195. <label class="theme-selector-label">
  196. Theme
  197. <select class="theme-selector" oninput="activateTheme(this.value)">
  198. <option value="auto" selected>Auto</option>
  199. <option value="light">Light</option>
  200. <option value="dark">Dark</option>
  201. </select>
  202. </label> |</li>
  203. </ul>
  204. </div>
  205. <div class="document">
  206. <div class="documentwrapper">
  207. <div class="bodywrapper">
  208. <div class="body" role="main">
  209. <section id="idle">
  210. <span id="id1"></span><h1>IDLE<a class="headerlink" href="#idle" title="Link to this heading">¶</a></h1>
  211. <p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.12/Lib/idlelib/">Lib/idlelib/</a></p>
  212. <hr class="docutils" id="index-0" />
  213. <p>IDLE is Python’s Integrated Development and Learning Environment.</p>
  214. <p>IDLE has the following features:</p>
  215. <ul class="simple">
  216. <li><p>cross-platform: works mostly the same on Windows, Unix, and macOS</p></li>
  217. <li><p>Python shell window (interactive interpreter) with colorizing
  218. of code input, output, and error messages</p></li>
  219. <li><p>multi-window text editor with multiple undo, Python colorizing,
  220. smart indent, call tips, auto completion, and other features</p></li>
  221. <li><p>search within any window, replace within editor windows, and search
  222. through multiple files (grep)</p></li>
  223. <li><p>debugger with persistent breakpoints, stepping, and viewing
  224. of global and local namespaces</p></li>
  225. <li><p>configuration, browsers, and other dialogs</p></li>
  226. </ul>
  227. <section id="menus">
  228. <h2>Menus<a class="headerlink" href="#menus" title="Link to this heading">¶</a></h2>
  229. <p>IDLE has two main window types, the Shell window and the Editor window. It is
  230. possible to have multiple editor windows simultaneously. On Windows and
  231. Linux, each has its own top menu. Each menu documented below indicates
  232. which window type it is associated with.</p>
  233. <p>Output windows, such as used for Edit =&gt; Find in Files, are a subtype of editor
  234. window. They currently have the same top menu but a different
  235. default title and context menu.</p>
  236. <p>On macOS, there is one application menu. It dynamically changes according
  237. to the window currently selected. It has an IDLE menu, and some entries
  238. described below are moved around to conform to Apple guidelines.</p>
  239. <section id="file-menu-shell-and-editor">
  240. <h3>File menu (Shell and Editor)<a class="headerlink" href="#file-menu-shell-and-editor" title="Link to this heading">¶</a></h3>
  241. <dl class="simple">
  242. <dt>New File</dt><dd><p>Create a new file editing window.</p>
  243. </dd>
  244. <dt>Open…</dt><dd><p>Open an existing file with an Open dialog.</p>
  245. </dd>
  246. <dt>Open Module…</dt><dd><p>Open an existing module (searches sys.path).</p>
  247. </dd>
  248. <dt>Recent Files</dt><dd><p>Open a list of recent files. Click one to open it.</p>
  249. </dd>
  250. </dl>
  251. <dl class="simple" id="index-1">
  252. <dt>Module Browser</dt><dd><p>Show functions, classes, and methods in the current Editor file in a
  253. tree structure. In the shell, open a module first.</p>
  254. </dd>
  255. <dt>Path Browser</dt><dd><p>Show sys.path directories, modules, functions, classes and methods in a
  256. tree structure.</p>
  257. </dd>
  258. <dt>Save</dt><dd><p>Save the current window to the associated file, if there is one. Windows
  259. that have been changed since being opened or last saved have a * before
  260. and after the window title. If there is no associated file,
  261. do Save As instead.</p>
  262. </dd>
  263. <dt>Save As…</dt><dd><p>Save the current window with a Save As dialog. The file saved becomes the
  264. new associated file for the window. (If your file namager is set to hide
  265. extensions, the current extension will be omitted in the file name box.
  266. If the new filename has no ‘.’, ‘.py’ and ‘.txt’ will be added for Python
  267. and text files, except that on macOS Aqua,’.py’ is added for all files.)</p>
  268. </dd>
  269. <dt>Save Copy As…</dt><dd><p>Save the current window to different file without changing the associated
  270. file. (See Save As note above about filename extensions.)</p>
  271. </dd>
  272. <dt>Print Window</dt><dd><p>Print the current window to the default printer.</p>
  273. </dd>
  274. <dt>Close Window</dt><dd><p>Close the current window (if an unsaved editor, ask to save; if an unsaved
  275. Shell, ask to quit execution). Calling <code class="docutils literal notranslate"><span class="pre">exit()</span></code> or <code class="docutils literal notranslate"><span class="pre">close()</span></code> in the Shell
  276. window also closes Shell. If this is the only window, also exit IDLE.</p>
  277. </dd>
  278. <dt>Exit IDLE</dt><dd><p>Close all windows and quit IDLE (ask to save unsaved edit windows).</p>
  279. </dd>
  280. </dl>
  281. </section>
  282. <section id="edit-menu-shell-and-editor">
  283. <h3>Edit menu (Shell and Editor)<a class="headerlink" href="#edit-menu-shell-and-editor" title="Link to this heading">¶</a></h3>
  284. <dl class="simple">
  285. <dt>Undo</dt><dd><p>Undo the last change to the current window. A maximum of 1000 changes may
  286. be undone.</p>
  287. </dd>
  288. <dt>Redo</dt><dd><p>Redo the last undone change to the current window.</p>
  289. </dd>
  290. <dt>Select All</dt><dd><p>Select the entire contents of the current window.</p>
  291. </dd>
  292. <dt>Cut</dt><dd><p>Copy selection into the system-wide clipboard; then delete the selection.</p>
  293. </dd>
  294. <dt>Copy</dt><dd><p>Copy selection into the system-wide clipboard.</p>
  295. </dd>
  296. <dt>Paste</dt><dd><p>Insert contents of the system-wide clipboard into the current window.</p>
  297. </dd>
  298. </dl>
  299. <p>The clipboard functions are also available in context menus.</p>
  300. <dl class="simple">
  301. <dt>Find…</dt><dd><p>Open a search dialog with many options</p>
  302. </dd>
  303. <dt>Find Again</dt><dd><p>Repeat the last search, if there is one.</p>
  304. </dd>
  305. <dt>Find Selection</dt><dd><p>Search for the currently selected string, if there is one.</p>
  306. </dd>
  307. <dt>Find in Files…</dt><dd><p>Open a file search dialog. Put results in a new output window.</p>
  308. </dd>
  309. <dt>Replace…</dt><dd><p>Open a search-and-replace dialog.</p>
  310. </dd>
  311. <dt>Go to Line</dt><dd><p>Move the cursor to the beginning of the line requested and make that
  312. line visible. A request past the end of the file goes to the end.
  313. Clear any selection and update the line and column status.</p>
  314. </dd>
  315. <dt>Show Completions</dt><dd><p>Open a scrollable list allowing selection of existing names. See
  316. <a class="reference internal" href="#completions"><span class="std std-ref">Completions</span></a> in the Editing and navigation section below.</p>
  317. </dd>
  318. <dt>Expand Word</dt><dd><p>Expand a prefix you have typed to match a full word in the same window;
  319. repeat to get a different expansion.</p>
  320. </dd>
  321. <dt>Show Call Tip</dt><dd><p>After an unclosed parenthesis for a function, open a small window with
  322. function parameter hints. See <a class="reference internal" href="#calltips"><span class="std std-ref">Calltips</span></a> in the
  323. Editing and navigation section below.</p>
  324. </dd>
  325. <dt>Show Surrounding Parens</dt><dd><p>Highlight the surrounding parenthesis.</p>
  326. </dd>
  327. </dl>
  328. </section>
  329. <section id="format-menu-editor-window-only">
  330. <span id="format-menu"></span><h3>Format menu (Editor window only)<a class="headerlink" href="#format-menu-editor-window-only" title="Link to this heading">¶</a></h3>
  331. <dl class="simple">
  332. <dt>Format Paragraph</dt><dd><p>Reformat the current blank-line-delimited paragraph in comment block or
  333. multiline string or selected line in a string. All lines in the
  334. paragraph will be formatted to less than N columns, where N defaults to 72.</p>
  335. </dd>
  336. <dt>Indent Region</dt><dd><p>Shift selected lines right by the indent width (default 4 spaces).</p>
  337. </dd>
  338. <dt>Dedent Region</dt><dd><p>Shift selected lines left by the indent width (default 4 spaces).</p>
  339. </dd>
  340. <dt>Comment Out Region</dt><dd><p>Insert ## in front of selected lines.</p>
  341. </dd>
  342. <dt>Uncomment Region</dt><dd><p>Remove leading # or ## from selected lines.</p>
  343. </dd>
  344. <dt>Tabify Region</dt><dd><p>Turn <em>leading</em> stretches of spaces into tabs. (Note: We recommend using
  345. 4 space blocks to indent Python code.)</p>
  346. </dd>
  347. <dt>Untabify Region</dt><dd><p>Turn <em>all</em> tabs into the correct number of spaces.</p>
  348. </dd>
  349. <dt>Toggle Tabs</dt><dd><p>Open a dialog to switch between indenting with spaces and tabs.</p>
  350. </dd>
  351. <dt>New Indent Width</dt><dd><p>Open a dialog to change indent width. The accepted default by the Python
  352. community is 4 spaces.</p>
  353. </dd>
  354. <dt>Strip Trailing Chitespace</dt><dd><p>Remove trailing space and other whitespace characters after the last
  355. non-whitespace character of a line by applying str.rstrip to each line,
  356. including lines within multiline strings. Except for Shell windows,
  357. remove extra newlines at the end of the file.</p>
  358. </dd>
  359. </dl>
  360. </section>
  361. <section id="run-menu-editor-window-only">
  362. <span id="index-2"></span><h3>Run menu (Editor window only)<a class="headerlink" href="#run-menu-editor-window-only" title="Link to this heading">¶</a></h3>
  363. <dl class="simple" id="run-module">
  364. <dt>Run Module</dt><dd><p>Do <a class="reference internal" href="#check-module"><span class="std std-ref">Check Module</span></a>. If no error, restart the shell to clean the
  365. environment, then execute the module. Output is displayed in the Shell
  366. window. Note that output requires use of <code class="docutils literal notranslate"><span class="pre">print</span></code> or <code class="docutils literal notranslate"><span class="pre">write</span></code>.
  367. When execution is complete, the Shell retains focus and displays a prompt.
  368. At this point, one may interactively explore the result of execution.
  369. This is similar to executing a file with <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-i</span> <span class="pre">file</span></code> at a command
  370. line.</p>
  371. </dd>
  372. </dl>
  373. <dl class="simple" id="run-custom">
  374. <dt>Run… Customized</dt><dd><p>Same as <a class="reference internal" href="#run-module"><span class="std std-ref">Run Module</span></a>, but run the module with customized
  375. settings. <em>Command Line Arguments</em> extend <a class="reference internal" href="sys.html#sys.argv" title="sys.argv"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.argv</span></code></a> as if passed
  376. on a command line. The module can be run in the Shell without restarting.</p>
  377. </dd>
  378. </dl>
  379. <dl class="simple" id="check-module">
  380. <dt>Check Module</dt><dd><p>Check the syntax of the module currently open in the Editor window. If the
  381. module has not been saved IDLE will either prompt the user to save or
  382. autosave, as selected in the General tab of the Idle Settings dialog. If
  383. there is a syntax error, the approximate location is indicated in the
  384. Editor window.</p>
  385. </dd>
  386. </dl>
  387. <dl class="simple" id="python-shell">
  388. <dt>Python Shell</dt><dd><p>Open or wake up the Python Shell window.</p>
  389. </dd>
  390. </dl>
  391. </section>
  392. <section id="shell-menu-shell-window-only">
  393. <h3>Shell menu (Shell window only)<a class="headerlink" href="#shell-menu-shell-window-only" title="Link to this heading">¶</a></h3>
  394. <dl class="simple">
  395. <dt>View Last Restart</dt><dd><p>Scroll the shell window to the last Shell restart.</p>
  396. </dd>
  397. <dt>Restart Shell</dt><dd><p>Restart the shell to clean the environment and reset display and exception handling.</p>
  398. </dd>
  399. <dt>Previous History</dt><dd><p>Cycle through earlier commands in history which match the current entry.</p>
  400. </dd>
  401. <dt>Next History</dt><dd><p>Cycle through later commands in history which match the current entry.</p>
  402. </dd>
  403. <dt>Interrupt Execution</dt><dd><p>Stop a running program.</p>
  404. </dd>
  405. </dl>
  406. </section>
  407. <section id="debug-menu-shell-window-only">
  408. <h3>Debug menu (Shell window only)<a class="headerlink" href="#debug-menu-shell-window-only" title="Link to this heading">¶</a></h3>
  409. <dl class="simple">
  410. <dt>Go to File/Line</dt><dd><p>Look on the current line. with the cursor, and the line above for a filename
  411. and line number. If found, open the file if not already open, and show the
  412. line. Use this to view source lines referenced in an exception traceback
  413. and lines found by Find in Files. Also available in the context menu of
  414. the Shell window and Output windows.</p>
  415. </dd>
  416. </dl>
  417. <dl class="simple" id="index-3">
  418. <dt>Debugger (toggle)</dt><dd><p>When activated, code entered in the Shell or run from an Editor will run
  419. under the debugger. In the Editor, breakpoints can be set with the context
  420. menu. This feature is still incomplete and somewhat experimental.</p>
  421. </dd>
  422. <dt>Stack Viewer</dt><dd><p>Show the stack traceback of the last exception in a tree widget, with
  423. access to locals and globals.</p>
  424. </dd>
  425. <dt>Auto-open Stack Viewer</dt><dd><p>Toggle automatically opening the stack viewer on an unhandled exception.</p>
  426. </dd>
  427. </dl>
  428. </section>
  429. <section id="options-menu-shell-and-editor">
  430. <h3>Options menu (Shell and Editor)<a class="headerlink" href="#options-menu-shell-and-editor" title="Link to this heading">¶</a></h3>
  431. <dl class="simple">
  432. <dt>Configure IDLE</dt><dd><p>Open a configuration dialog and change preferences for the following:
  433. fonts, indentation, keybindings, text color themes, startup windows and
  434. size, additional help sources, and extensions. On macOS, open the
  435. configuration dialog by selecting Preferences in the application
  436. menu. For more details, see
  437. <a class="reference internal" href="#preferences"><span class="std std-ref">Setting preferences</span></a> under Help and preferences.</p>
  438. </dd>
  439. </dl>
  440. <p>Most configuration options apply to all windows or all future windows.
  441. The option items below only apply to the active window.</p>
  442. <dl class="simple">
  443. <dt>Show/Hide Code Context (Editor Window only)</dt><dd><p>Open a pane at the top of the edit window which shows the block context
  444. of the code which has scrolled above the top of the window. See
  445. <a class="reference internal" href="#code-context"><span class="std std-ref">Code Context</span></a> in the Editing and Navigation section
  446. below.</p>
  447. </dd>
  448. <dt>Show/Hide Line Numbers (Editor Window only)</dt><dd><p>Open a column to the left of the edit window which shows the number
  449. of each line of text. The default is off, which may be changed in the
  450. preferences (see <a class="reference internal" href="#preferences"><span class="std std-ref">Setting preferences</span></a>).</p>
  451. </dd>
  452. <dt>Zoom/Restore Height</dt><dd><p>Toggles the window between normal size and maximum height. The initial size
  453. defaults to 40 lines by 80 chars unless changed on the General tab of the
  454. Configure IDLE dialog. The maximum height for a screen is determined by
  455. momentarily maximizing a window the first time one is zoomed on the screen.
  456. Changing screen settings may invalidate the saved height. This toggle has
  457. no effect when a window is maximized.</p>
  458. </dd>
  459. </dl>
  460. </section>
  461. <section id="window-menu-shell-and-editor">
  462. <h3>Window menu (Shell and Editor)<a class="headerlink" href="#window-menu-shell-and-editor" title="Link to this heading">¶</a></h3>
  463. <p>Lists the names of all open windows; select one to bring it to the foreground
  464. (deiconifying it if necessary).</p>
  465. </section>
  466. <section id="help-menu-shell-and-editor">
  467. <h3>Help menu (Shell and Editor)<a class="headerlink" href="#help-menu-shell-and-editor" title="Link to this heading">¶</a></h3>
  468. <dl class="simple">
  469. <dt>About IDLE</dt><dd><p>Display version, copyright, license, credits, and more.</p>
  470. </dd>
  471. <dt>IDLE Help</dt><dd><p>Display this IDLE document, detailing the menu options, basic editing and
  472. navigation, and other tips.</p>
  473. </dd>
  474. <dt>Python Docs</dt><dd><p>Access local Python documentation, if installed, or start a web browser
  475. and open docs.python.org showing the latest Python documentation.</p>
  476. </dd>
  477. <dt>Turtle Demo</dt><dd><p>Run the turtledemo module with example Python code and turtle drawings.</p>
  478. </dd>
  479. </dl>
  480. <p>Additional help sources may be added here with the Configure IDLE dialog under
  481. the General tab. See the <a class="reference internal" href="#help-sources"><span class="std std-ref">Help sources</span></a> subsection below
  482. for more on Help menu choices.</p>
  483. </section>
  484. <section id="context-menus">
  485. <span id="index-4"></span><h3>Context menus<a class="headerlink" href="#context-menus" title="Link to this heading">¶</a></h3>
  486. <p>Open a context menu by right-clicking in a window (Control-click on macOS).
  487. Context menus have the standard clipboard functions also on the Edit menu.</p>
  488. <dl class="simple">
  489. <dt>Cut</dt><dd><p>Copy selection into the system-wide clipboard; then delete the selection.</p>
  490. </dd>
  491. <dt>Copy</dt><dd><p>Copy selection into the system-wide clipboard.</p>
  492. </dd>
  493. <dt>Paste</dt><dd><p>Insert contents of the system-wide clipboard into the current window.</p>
  494. </dd>
  495. </dl>
  496. <p>Editor windows also have breakpoint functions. Lines with a breakpoint set are
  497. specially marked. Breakpoints only have an effect when running under the
  498. debugger. Breakpoints for a file are saved in the user’s <code class="docutils literal notranslate"><span class="pre">.idlerc</span></code>
  499. directory.</p>
  500. <dl class="simple">
  501. <dt>Set Breakpoint</dt><dd><p>Set a breakpoint on the current line.</p>
  502. </dd>
  503. <dt>Clear Breakpoint</dt><dd><p>Clear the breakpoint on that line.</p>
  504. </dd>
  505. </dl>
  506. <p>Shell and Output windows also have the following.</p>
  507. <dl class="simple">
  508. <dt>Go to file/line</dt><dd><p>Same as in Debug menu.</p>
  509. </dd>
  510. </dl>
  511. <p>The Shell window also has an output squeezing facility explained in the <em>Python
  512. Shell window</em> subsection below.</p>
  513. <dl class="simple">
  514. <dt>Squeeze</dt><dd><p>If the cursor is over an output line, squeeze all the output between
  515. the code above and the prompt below down to a ‘Squeezed text’ label.</p>
  516. </dd>
  517. </dl>
  518. </section>
  519. </section>
  520. <section id="editing-and-navigation">
  521. <span id="id2"></span><h2>Editing and Navigation<a class="headerlink" href="#editing-and-navigation" title="Link to this heading">¶</a></h2>
  522. <section id="editor-windows">
  523. <h3>Editor windows<a class="headerlink" href="#editor-windows" title="Link to this heading">¶</a></h3>
  524. <p>IDLE may open editor windows when it starts, depending on settings
  525. and how you start IDLE. Thereafter, use the File menu. There can be only
  526. one open editor window for a given file.</p>
  527. <p>The title bar contains the name of the file, the full path, and the version
  528. of Python and IDLE running the window. The status bar contains the line
  529. number (‘Ln’) and column number (‘Col’). Line numbers start with 1;
  530. column numbers with 0.</p>
  531. <p>IDLE assumes that files with a known .py* extension contain Python code
  532. and that other files do not. Run Python code with the Run menu.</p>
  533. </section>
  534. <section id="key-bindings">
  535. <h3>Key bindings<a class="headerlink" href="#key-bindings" title="Link to this heading">¶</a></h3>
  536. <p>The IDLE insertion cursor is a thin vertical bar between character
  537. positions. When characters are entered, the insertion cursor and
  538. everything to its right moves right one character and
  539. the new character is entered in the new space.</p>
  540. <p>Several non-character keys move the cursor and possibly
  541. delete characters. Deletion does not puts text on the clipboard,
  542. but IDLE has an undo list. Wherever this doc discusses keys,
  543. ‘C’ refers to the <kbd class="kbd docutils literal notranslate">Control</kbd> key on Windows and
  544. Unix and the <kbd class="kbd docutils literal notranslate">Command</kbd> key on macOS. (And all such dicussions
  545. assume that the keys have not been re-bound to something else.)</p>
  546. <ul class="simple">
  547. <li><p>Arrow keys move the cursor one character or line.</p></li>
  548. <li><p><kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">LeftArrow</kbd></kbd> and <kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">RightArrow</kbd></kbd> moves left or right one word.</p></li>
  549. <li><p><kbd class="kbd docutils literal notranslate">Home</kbd> and <kbd class="kbd docutils literal notranslate">End</kbd> go to the beginning or end of the line.</p></li>
  550. <li><p><kbd class="kbd docutils literal notranslate">Page Up</kbd> and <kbd class="kbd docutils literal notranslate">Page Down</kbd> go up or down one screen.</p></li>
  551. <li><p><kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">Home</kbd></kbd> and <kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">End</kbd></kbd> go to beginning or end of the file.</p></li>
  552. <li><p><kbd class="kbd docutils literal notranslate">Backspace</kbd> and <kbd class="kbd docutils literal notranslate">Del</kbd> (or <kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">d</kbd></kbd>) delete the previous
  553. or next character.</p></li>
  554. <li><p><kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">Backspace</kbd></kbd> and <kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">Del</kbd></kbd> delete one word left or right.</p></li>
  555. <li><p><kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">k</kbd></kbd> deletes (‘kills’) everything to the right.</p></li>
  556. </ul>
  557. <p>Standard keybindings (like <kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">c</kbd></kbd> to copy and <kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">v</kbd></kbd> to paste)
  558. may work. Keybindings are selected in the Configure IDLE dialog.</p>
  559. </section>
  560. <section id="automatic-indentation">
  561. <h3>Automatic indentation<a class="headerlink" href="#automatic-indentation" title="Link to this heading">¶</a></h3>
  562. <p>After a block-opening statement, the next line is indented by 4 spaces (in the
  563. Python Shell window by one tab). After certain keywords (break, return etc.)
  564. the next line is dedented. In leading indentation, <kbd class="kbd docutils literal notranslate">Backspace</kbd> deletes up
  565. to 4 spaces if they are there. <kbd class="kbd docutils literal notranslate">Tab</kbd> inserts spaces (in the Python
  566. Shell window one tab), number depends on Indent width. Currently, tabs
  567. are restricted to four spaces due to Tcl/Tk limitations.</p>
  568. <p>See also the indent/dedent region commands on the
  569. <a class="reference internal" href="#format-menu"><span class="std std-ref">Format menu</span></a>.</p>
  570. </section>
  571. <section id="search-and-replace">
  572. <h3>Search and Replace<a class="headerlink" href="#search-and-replace" title="Link to this heading">¶</a></h3>
  573. <p>Any selection becomes a search target. However, only selections within
  574. a line work because searches are only performed within lines with the
  575. terminal newline removed. If <code class="docutils literal notranslate"><span class="pre">[x]</span> <span class="pre">Regular</span> <span class="pre">expression</span></code> is checked, the
  576. target is interpreted according to the Python re module.</p>
  577. </section>
  578. <section id="completions">
  579. <span id="id3"></span><h3>Completions<a class="headerlink" href="#completions" title="Link to this heading">¶</a></h3>
  580. <p>Completions are supplied, when requested and available, for module
  581. names, attributes of classes or functions, or filenames. Each request
  582. method displays a completion box with existing names. (See tab
  583. completions below for an exception.) For any box, change the name
  584. being completed and the item highlighted in the box by
  585. typing and deleting characters; by hitting <kbd class="kbd docutils literal notranslate">Up</kbd>, <kbd class="kbd docutils literal notranslate">Down</kbd>,
  586. <kbd class="kbd docutils literal notranslate">PageUp</kbd>, <kbd class="kbd docutils literal notranslate">PageDown</kbd>, <kbd class="kbd docutils literal notranslate">Home</kbd>, and <kbd class="kbd docutils literal notranslate">End</kbd> keys;
  587. and by a single click within the box. Close the box with <kbd class="kbd docutils literal notranslate">Escape</kbd>,
  588. <kbd class="kbd docutils literal notranslate">Enter</kbd>, and double <kbd class="kbd docutils literal notranslate">Tab</kbd> keys or clicks outside the box.
  589. A double click within the box selects and closes.</p>
  590. <p>One way to open a box is to type a key character and wait for a
  591. predefined interval. This defaults to 2 seconds; customize it
  592. in the settings dialog. (To prevent auto popups, set the delay to a
  593. large number of milliseconds, such as 100000000.) For imported module
  594. names or class or function attributes, type ‘.’.
  595. For filenames in the root directory, type <a class="reference internal" href="os.html#os.sep" title="os.sep"><code class="xref py py-data docutils literal notranslate"><span class="pre">os.sep</span></code></a> or
  596. <a class="reference internal" href="os.html#os.altsep" title="os.altsep"><code class="xref py py-data docutils literal notranslate"><span class="pre">os.altsep</span></code></a> immediately after an opening quote. (On Windows,
  597. one can specify a drive first.) Move into subdirectories by typing a
  598. directory name and a separator.</p>
  599. <p>Instead of waiting, or after a box is closed, open a completion box
  600. immediately with Show Completions on the Edit menu. The default hot
  601. key is <kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">space</kbd></kbd>. If one types a prefix for the desired name
  602. before opening the box, the first match or near miss is made visible.
  603. The result is the same as if one enters a prefix
  604. after the box is displayed. Show Completions after a quote completes
  605. filenames in the current directory instead of a root directory.</p>
  606. <p>Hitting <kbd class="kbd docutils literal notranslate">Tab</kbd> after a prefix usually has the same effect as Show
  607. Completions. (With no prefix, it indents.) However, if there is only
  608. one match to the prefix, that match is immediately added to the editor
  609. text without opening a box.</p>
  610. <p>Invoking ‘Show Completions’, or hitting <kbd class="kbd docutils literal notranslate">Tab</kbd> after a prefix,
  611. outside of a string and without a preceding ‘.’ opens a box with
  612. keywords, builtin names, and available module-level names.</p>
  613. <p>When editing code in an editor (as oppose to Shell), increase the
  614. available module-level names by running your code
  615. and not restarting the Shell thereafter. This is especially useful
  616. after adding imports at the top of a file. This also increases
  617. possible attribute completions.</p>
  618. <p>Completion boxes initially exclude names beginning with ‘_’ or, for
  619. modules, not included in ‘__all__’. The hidden names can be accessed
  620. by typing ‘_’ after ‘.’, either before or after the box is opened.</p>
  621. </section>
  622. <section id="calltips">
  623. <span id="id4"></span><h3>Calltips<a class="headerlink" href="#calltips" title="Link to this heading">¶</a></h3>
  624. <p>A calltip is shown automatically when one types <kbd class="kbd docutils literal notranslate">(</kbd> after the name
  625. of an <em>accessible</em> function. A function name expression may include
  626. dots and subscripts. A calltip remains until it is clicked, the cursor
  627. is moved out of the argument area, or <kbd class="kbd docutils literal notranslate">)</kbd> is typed. Whenever the
  628. cursor is in the argument part of a definition, select Edit and “Show
  629. Call Tip” on the menu or enter its shortcut to display a calltip.</p>
  630. <p>The calltip consists of the function’s signature and docstring up to
  631. the latter’s first blank line or the fifth non-blank line. (Some builtin
  632. functions lack an accessible signature.) A ‘/’ or ‘*’ in the signature
  633. indicates that the preceding or following arguments are passed by
  634. position or name (keyword) only. Details are subject to change.</p>
  635. <p>In Shell, the accessible functions depends on what modules have been
  636. imported into the user process, including those imported by Idle itself,
  637. and which definitions have been run, all since the last restart.</p>
  638. <p>For example, restart the Shell and enter <code class="docutils literal notranslate"><span class="pre">itertools.count(</span></code>. A calltip
  639. appears because Idle imports itertools into the user process for its own
  640. use. (This could change.) Enter <code class="docutils literal notranslate"><span class="pre">turtle.write(</span></code> and nothing appears.
  641. Idle does not itself import turtle. The menu entry and shortcut also do
  642. nothing. Enter <code class="docutils literal notranslate"><span class="pre">import</span> <span class="pre">turtle</span></code>. Thereafter, <code class="docutils literal notranslate"><span class="pre">turtle.write(</span></code>
  643. will display a calltip.</p>
  644. <p>In an editor, import statements have no effect until one runs the file.
  645. One might want to run a file after writing import statements, after
  646. adding function definitions, or after opening an existing file.</p>
  647. </section>
  648. <section id="code-context">
  649. <span id="id5"></span><h3>Code Context<a class="headerlink" href="#code-context" title="Link to this heading">¶</a></h3>
  650. <p>Within an editor window containing Python code, code context can be toggled
  651. in order to show or hide a pane at the top of the window. When shown, this
  652. pane freezes the opening lines for block code, such as those beginning with
  653. <code class="docutils literal notranslate"><span class="pre">class</span></code>, <code class="docutils literal notranslate"><span class="pre">def</span></code>, or <code class="docutils literal notranslate"><span class="pre">if</span></code> keywords, that would have otherwise scrolled
  654. out of view. The size of the pane will be expanded and contracted as needed
  655. to show the all current levels of context, up to the maximum number of
  656. lines defined in the Configure IDLE dialog (which defaults to 15). If there
  657. are no current context lines and the feature is toggled on, a single blank
  658. line will display. Clicking on a line in the context pane will move that
  659. line to the top of the editor.</p>
  660. <p>The text and background colors for the context pane can be configured under
  661. the Highlights tab in the Configure IDLE dialog.</p>
  662. </section>
  663. <section id="shell-window">
  664. <h3>Shell window<a class="headerlink" href="#shell-window" title="Link to this heading">¶</a></h3>
  665. <p>In IDLE’s Shell, enter, edit, and recall complete statements. (Most
  666. consoles and terminals only work with a single physical line at a time).</p>
  667. <p>Submit a single-line statement for execution by hitting <kbd class="kbd docutils literal notranslate">Return</kbd>
  668. with the cursor anywhere on the line. If a line is extended with
  669. Backslash (<kbd class="kbd docutils literal notranslate">\</kbd>), the cursor must be on the last physical line.
  670. Submit a multi-line compound statement by entering a blank line after
  671. the statement.</p>
  672. <p>When one pastes code into Shell, it is not compiled and possibly executed
  673. until one hits <kbd class="kbd docutils literal notranslate">Return</kbd>, as specified above.
  674. One may edit pasted code first.
  675. If one pastes more than one statement into Shell, the result will be a
  676. <a class="reference internal" href="exceptions.html#SyntaxError" title="SyntaxError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SyntaxError</span></code></a> when multiple statements are compiled as if they were one.</p>
  677. <p>Lines containing <code class="docutils literal notranslate"><span class="pre">RESTART</span></code> mean that the user execution process has been
  678. re-started. This occurs when the user execution process has crashed,
  679. when one requests a restart on the Shell menu, or when one runs code
  680. in an editor window.</p>
  681. <p>The editing features described in previous subsections work when entering
  682. code interactively. IDLE’s Shell window also responds to the following:</p>
  683. <ul class="simple">
  684. <li><p><kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">c</kbd></kbd> attempts to interrupt statement execution (but may fail).</p></li>
  685. <li><p><kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">d</kbd></kbd> closes Shell if typed at a <code class="docutils literal notranslate"><span class="pre">&gt;&gt;&gt;</span></code> prompt.</p></li>
  686. <li><p><kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">Alt</kbd>-<kbd class="kbd docutils literal notranslate">p</kbd></kbd> and <kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">Alt</kbd>-<kbd class="kbd docutils literal notranslate">n</kbd></kbd> (<kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">p</kbd></kbd> and <kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">C</kbd>-<kbd class="kbd docutils literal notranslate">n</kbd></kbd> on macOS)
  687. retrieve to the current prompt the previous or next previously
  688. entered statement that matches anything already typed.</p></li>
  689. <li><p><kbd class="kbd docutils literal notranslate">Return</kbd> while the cursor is on any previous statement
  690. appends the latter to anything already typed at the prompt.</p></li>
  691. </ul>
  692. </section>
  693. <section id="text-colors">
  694. <h3>Text colors<a class="headerlink" href="#text-colors" title="Link to this heading">¶</a></h3>
  695. <p>Idle defaults to black on white text, but colors text with special meanings.
  696. For the shell, these are shell output, shell error, user output, and
  697. user error. For Python code, at the shell prompt or in an editor, these are
  698. keywords, builtin class and function names, names following <code class="docutils literal notranslate"><span class="pre">class</span></code> and
  699. <code class="docutils literal notranslate"><span class="pre">def</span></code>, strings, and comments. For any text window, these are the cursor (when
  700. present), found text (when possible), and selected text.</p>
  701. <p>IDLE also highlights the <a class="reference internal" href="../reference/lexical_analysis.html#soft-keywords"><span class="std std-ref">soft keywords</span></a> <a class="reference internal" href="../reference/compound_stmts.html#match"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">match</span></code></a>,
  702. <a class="reference internal" href="../reference/compound_stmts.html#match"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">case</span></code></a>, and <a class="reference internal" href="../reference/compound_stmts.html#wildcard-patterns"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">_</span></code></a> in
  703. pattern-matching statements. However, this highlighting is not perfect and
  704. will be incorrect in some rare cases, including some <code class="docutils literal notranslate"><span class="pre">_</span></code>-s in <code class="docutils literal notranslate"><span class="pre">case</span></code>
  705. patterns.</p>
  706. <p>Text coloring is done in the background, so uncolorized text is occasionally
  707. visible. To change the color scheme, use the Configure IDLE dialog
  708. Highlighting tab. The marking of debugger breakpoint lines in the editor and
  709. text in popups and dialogs is not user-configurable.</p>
  710. </section>
  711. </section>
  712. <section id="startup-and-code-execution">
  713. <h2>Startup and Code Execution<a class="headerlink" href="#startup-and-code-execution" title="Link to this heading">¶</a></h2>
  714. <p>Upon startup with the <code class="docutils literal notranslate"><span class="pre">-s</span></code> option, IDLE will execute the file referenced by
  715. the environment variables <span class="target" id="index-5"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">IDLESTARTUP</span></code> or <span class="target" id="index-6"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONSTARTUP"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONSTARTUP</span></code></a>.
  716. IDLE first checks for <code class="docutils literal notranslate"><span class="pre">IDLESTARTUP</span></code>; if <code class="docutils literal notranslate"><span class="pre">IDLESTARTUP</span></code> is present the file
  717. referenced is run. If <code class="docutils literal notranslate"><span class="pre">IDLESTARTUP</span></code> is not present, IDLE checks for
  718. <code class="docutils literal notranslate"><span class="pre">PYTHONSTARTUP</span></code>. Files referenced by these environment variables are
  719. convenient places to store functions that are used frequently from the IDLE
  720. shell, or for executing import statements to import common modules.</p>
  721. <p>In addition, <code class="docutils literal notranslate"><span class="pre">Tk</span></code> also loads a startup file if it is present. Note that the
  722. Tk file is loaded unconditionally. This additional file is <code class="docutils literal notranslate"><span class="pre">.Idle.py</span></code> and is
  723. looked for in the user’s home directory. Statements in this file will be
  724. executed in the Tk namespace, so this file is not useful for importing
  725. functions to be used from IDLE’s Python shell.</p>
  726. <section id="command-line-usage">
  727. <h3>Command line usage<a class="headerlink" href="#command-line-usage" title="Link to this heading">¶</a></h3>
  728. <div class="highlight-none notranslate"><div class="highlight"><pre><span></span>idle.py [-c command] [-d] [-e] [-h] [-i] [-r file] [-s] [-t title] [-] [arg] ...
  729. -c command run command in the shell window
  730. -d enable debugger and open shell window
  731. -e open editor window
  732. -h print help message with legal combinations and exit
  733. -i open shell window
  734. -r file run file in shell window
  735. -s run $IDLESTARTUP or $PYTHONSTARTUP first, in shell window
  736. -t title set title of shell window
  737. - run stdin in shell (- must be last option before args)
  738. </pre></div>
  739. </div>
  740. <p>If there are arguments:</p>
  741. <ul class="simple">
  742. <li><p>If <code class="docutils literal notranslate"><span class="pre">-</span></code>, <code class="docutils literal notranslate"><span class="pre">-c</span></code>, or <code class="docutils literal notranslate"><span class="pre">r</span></code> is used, all arguments are placed in
  743. <code class="docutils literal notranslate"><span class="pre">sys.argv[1:...]</span></code> and <code class="docutils literal notranslate"><span class="pre">sys.argv[0]</span></code> is set to <code class="docutils literal notranslate"><span class="pre">''</span></code>, <code class="docutils literal notranslate"><span class="pre">'-c'</span></code>,
  744. or <code class="docutils literal notranslate"><span class="pre">'-r'</span></code>. No editor window is opened, even if that is the default
  745. set in the Options dialog.</p></li>
  746. <li><p>Otherwise, arguments are files opened for editing and
  747. <code class="docutils literal notranslate"><span class="pre">sys.argv</span></code> reflects the arguments passed to IDLE itself.</p></li>
  748. </ul>
  749. </section>
  750. <section id="startup-failure">
  751. <h3>Startup failure<a class="headerlink" href="#startup-failure" title="Link to this heading">¶</a></h3>
  752. <p>IDLE uses a socket to communicate between the IDLE GUI process and the user
  753. code execution process. A connection must be established whenever the Shell
  754. starts or restarts. (The latter is indicated by a divider line that says
  755. ‘RESTART’). If the user process fails to connect to the GUI process, it
  756. usually displays a <code class="docutils literal notranslate"><span class="pre">Tk</span></code> error box with a ‘cannot connect’ message
  757. that directs the user here. It then exits.</p>
  758. <p>One specific connection failure on Unix systems results from
  759. misconfigured masquerading rules somewhere in a system’s network setup.
  760. When IDLE is started from a terminal, one will see a message starting
  761. with <code class="docutils literal notranslate"><span class="pre">**</span> <span class="pre">Invalid</span> <span class="pre">host:</span></code>.
  762. The valid value is <code class="docutils literal notranslate"><span class="pre">127.0.0.1</span> <span class="pre">(idlelib.rpc.LOCALHOST)</span></code>.
  763. One can diagnose with <code class="docutils literal notranslate"><span class="pre">tcpconnect</span> <span class="pre">-irv</span> <span class="pre">127.0.0.1</span> <span class="pre">6543</span></code> in one
  764. terminal window and <code class="docutils literal notranslate"><span class="pre">tcplisten</span> <span class="pre">&lt;same</span> <span class="pre">args&gt;</span></code> in another.</p>
  765. <p>A common cause of failure is a user-written file with the same name as a
  766. standard library module, such as <em>random.py</em> and <em>tkinter.py</em>. When such a
  767. file is located in the same directory as a file that is about to be run,
  768. IDLE cannot import the stdlib file. The current fix is to rename the
  769. user file.</p>
  770. <p>Though less common than in the past, an antivirus or firewall program may
  771. stop the connection. If the program cannot be taught to allow the
  772. connection, then it must be turned off for IDLE to work. It is safe to
  773. allow this internal connection because no data is visible on external
  774. ports. A similar problem is a network mis-configuration that blocks
  775. connections.</p>
  776. <p>Python installation issues occasionally stop IDLE: multiple versions can
  777. clash, or a single installation might need admin access. If one undo the
  778. clash, or cannot or does not want to run as admin, it might be easiest to
  779. completely remove Python and start over.</p>
  780. <p>A zombie pythonw.exe process could be a problem. On Windows, use Task
  781. Manager to check for one and stop it if there is. Sometimes a restart
  782. initiated by a program crash or Keyboard Interrupt (control-C) may fail
  783. to connect. Dismissing the error box or using Restart Shell on the Shell
  784. menu may fix a temporary problem.</p>
  785. <p>When IDLE first starts, it attempts to read user configuration files in
  786. <code class="docutils literal notranslate"><span class="pre">~/.idlerc/</span></code> (~ is one’s home directory). If there is a problem, an error
  787. message should be displayed. Leaving aside random disk glitches, this can
  788. be prevented by never editing the files by hand. Instead, use the
  789. configuration dialog, under Options. Once there is an error in a user
  790. configuration file, the best solution may be to delete it and start over
  791. with the settings dialog.</p>
  792. <p>If IDLE quits with no message, and it was not started from a console, try
  793. starting it from a console or terminal (<code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-m</span> <span class="pre">idlelib</span></code>) and see if
  794. this results in an error message.</p>
  795. <p>On Unix-based systems with tcl/tk older than <code class="docutils literal notranslate"><span class="pre">8.6.11</span></code> (see
  796. <code class="docutils literal notranslate"><span class="pre">About</span> <span class="pre">IDLE</span></code>) certain characters of certain fonts can cause
  797. a tk failure with a message to the terminal. This can happen either
  798. if one starts IDLE to edit a file with such a character or later
  799. when entering such a character. If one cannot upgrade tcl/tk,
  800. then re-configure IDLE to use a font that works better.</p>
  801. </section>
  802. <section id="running-user-code">
  803. <h3>Running user code<a class="headerlink" href="#running-user-code" title="Link to this heading">¶</a></h3>
  804. <p>With rare exceptions, the result of executing Python code with IDLE is
  805. intended to be the same as executing the same code by the default method,
  806. directly with Python in a text-mode system console or terminal window.
  807. However, the different interface and operation occasionally affect
  808. visible results. For instance, <code class="docutils literal notranslate"><span class="pre">sys.modules</span></code> starts with more entries,
  809. and <code class="docutils literal notranslate"><span class="pre">threading.active_count()</span></code> returns 2 instead of 1.</p>
  810. <p>By default, IDLE runs user code in a separate OS process rather than in
  811. the user interface process that runs the shell and editor. In the execution
  812. process, it replaces <code class="docutils literal notranslate"><span class="pre">sys.stdin</span></code>, <code class="docutils literal notranslate"><span class="pre">sys.stdout</span></code>, and <code class="docutils literal notranslate"><span class="pre">sys.stderr</span></code>
  813. with objects that get input from and send output to the Shell window.
  814. The original values stored in <code class="docutils literal notranslate"><span class="pre">sys.__stdin__</span></code>, <code class="docutils literal notranslate"><span class="pre">sys.__stdout__</span></code>, and
  815. <code class="docutils literal notranslate"><span class="pre">sys.__stderr__</span></code> are not touched, but may be <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>
  816. <p>Sending print output from one process to a text widget in another is
  817. slower than printing to a system terminal in the same process.
  818. This has the most effect when printing multiple arguments, as the string
  819. for each argument, each separator, the newline are sent separately.
  820. For development, this is usually not a problem, but if one wants to
  821. print faster in IDLE, format and join together everything one wants
  822. displayed together and then print a single string. Both format strings
  823. and <a class="reference internal" href="stdtypes.html#str.join" title="str.join"><code class="xref py py-meth docutils literal notranslate"><span class="pre">str.join()</span></code></a> can help combine fields and lines.</p>
  824. <p>IDLE’s standard stream replacements are not inherited by subprocesses
  825. created in the execution process, whether directly by user code or by
  826. modules such as multiprocessing. If such subprocess use <code class="docutils literal notranslate"><span class="pre">input</span></code> from
  827. sys.stdin or <code class="docutils literal notranslate"><span class="pre">print</span></code> or <code class="docutils literal notranslate"><span class="pre">write</span></code> to sys.stdout or sys.stderr,
  828. IDLE should be started in a command line window. (On Windows,
  829. use <code class="docutils literal notranslate"><span class="pre">python</span></code> or <code class="docutils literal notranslate"><span class="pre">py</span></code> rather than <code class="docutils literal notranslate"><span class="pre">pythonw</span></code> or <code class="docutils literal notranslate"><span class="pre">pyw</span></code>.)
  830. The secondary subprocess
  831. will then be attached to that window for input and output.</p>
  832. <p>If <code class="docutils literal notranslate"><span class="pre">sys</span></code> is reset by user code, such as with <code class="docutils literal notranslate"><span class="pre">importlib.reload(sys)</span></code>,
  833. IDLE’s changes are lost and input from the keyboard and output to the screen
  834. will not work correctly.</p>
  835. <p>When Shell has the focus, it controls the keyboard and screen. This is
  836. normally transparent, but functions that directly access the keyboard
  837. and screen will not work. These include system-specific functions that
  838. determine whether a key has been pressed and if so, which.</p>
  839. <p>The IDLE code running in the execution process adds frames to the call stack
  840. that would not be there otherwise. IDLE wraps <code class="docutils literal notranslate"><span class="pre">sys.getrecursionlimit</span></code> and
  841. <code class="docutils literal notranslate"><span class="pre">sys.setrecursionlimit</span></code> to reduce the effect of the additional stack
  842. frames.</p>
  843. <p>When user code raises SystemExit either directly or by calling sys.exit,
  844. IDLE returns to a Shell prompt instead of exiting.</p>
  845. </section>
  846. <section id="user-output-in-shell">
  847. <h3>User output in Shell<a class="headerlink" href="#user-output-in-shell" title="Link to this heading">¶</a></h3>
  848. <p>When a program outputs text, the result is determined by the
  849. corresponding output device. When IDLE executes user code, <code class="docutils literal notranslate"><span class="pre">sys.stdout</span></code>
  850. and <code class="docutils literal notranslate"><span class="pre">sys.stderr</span></code> are connected to the display area of IDLE’s Shell. Some of
  851. its features are inherited from the underlying Tk Text widget. Others
  852. are programmed additions. Where it matters, Shell is designed for development
  853. rather than production runs.</p>
  854. <p>For instance, Shell never throws away output. A program that sends unlimited
  855. output to Shell will eventually fill memory, resulting in a memory error.
  856. In contrast, some system text windows only keep the last n lines of output.
  857. A Windows console, for instance, keeps a user-settable 1 to 9999 lines,
  858. with 300 the default.</p>
  859. <p>A Tk Text widget, and hence IDLE’s Shell, displays characters (codepoints) in
  860. the BMP (Basic Multilingual Plane) subset of Unicode. Which characters are
  861. displayed with a proper glyph and which with a replacement box depends on the
  862. operating system and installed fonts. Tab characters cause the following text
  863. to begin after the next tab stop. (They occur every 8 ‘characters’). Newline
  864. characters cause following text to appear on a new line. Other control
  865. characters are ignored or displayed as a space, box, or something else,
  866. depending on the operating system and font. (Moving the text cursor through
  867. such output with arrow keys may exhibit some surprising spacing behavior.)</p>
  868. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">s</span> <span class="o">=</span> <span class="s1">&#39;a</span><span class="se">\t</span><span class="s1">b</span><span class="se">\a</span><span class="s1">&lt;</span><span class="se">\x02</span><span class="s1">&gt;&lt;</span><span class="se">\r</span><span class="s1">&gt;</span><span class="se">\b</span><span class="s1">c</span><span class="se">\n</span><span class="s1">d&#39;</span> <span class="c1"># Enter 22 chars.</span>
  869. <span class="gp">&gt;&gt;&gt; </span><span class="nb">len</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
  870. <span class="go">14</span>
  871. <span class="gp">&gt;&gt;&gt; </span><span class="n">s</span> <span class="c1"># Display repr(s)</span>
  872. <span class="go">&#39;a\tb\x07&lt;\x02&gt;&lt;\r&gt;\x08c\nd&#39;</span>
  873. <span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">end</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">)</span> <span class="c1"># Display s as is.</span>
  874. <span class="go"># Result varies by OS and font. Try it.</span>
  875. </pre></div>
  876. </div>
  877. <p>The <code class="docutils literal notranslate"><span class="pre">repr</span></code> function is used for interactive echo of expression
  878. values. It returns an altered version of the input string in which
  879. control codes, some BMP codepoints, and all non-BMP codepoints are
  880. replaced with escape codes. As demonstrated above, it allows one to
  881. identify the characters in a string, regardless of how they are displayed.</p>
  882. <p>Normal and error output are generally kept separate (on separate lines)
  883. from code input and each other. They each get different highlight colors.</p>
  884. <p>For SyntaxError tracebacks, the normal ‘^’ marking where the error was
  885. detected is replaced by coloring the text with an error highlight.
  886. When code run from a file causes other exceptions, one may right click
  887. on a traceback line to jump to the corresponding line in an IDLE editor.
  888. The file will be opened if necessary.</p>
  889. <p>Shell has a special facility for squeezing output lines down to a
  890. ‘Squeezed text’ label. This is done automatically
  891. for output over N lines (N = 50 by default).
  892. N can be changed in the PyShell section of the General
  893. page of the Settings dialog. Output with fewer lines can be squeezed by
  894. right clicking on the output. This can be useful lines long enough to slow
  895. down scrolling.</p>
  896. <p>Squeezed output is expanded in place by double-clicking the label.
  897. It can also be sent to the clipboard or a separate view window by
  898. right-clicking the label.</p>
  899. </section>
  900. <section id="developing-tkinter-applications">
  901. <h3>Developing tkinter applications<a class="headerlink" href="#developing-tkinter-applications" title="Link to this heading">¶</a></h3>
  902. <p>IDLE is intentionally different from standard Python in order to
  903. facilitate development of tkinter programs. Enter <code class="docutils literal notranslate"><span class="pre">import</span> <span class="pre">tkinter</span> <span class="pre">as</span> <span class="pre">tk;</span>
  904. <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
  905. in IDLE and a tk window appears. In standard Python, one must also enter
  906. <code class="docutils literal notranslate"><span class="pre">root.update()</span></code> to see the window. IDLE does the equivalent in the
  907. background, about 20 times a second, which is about every 50 milliseconds.
  908. Next enter <code class="docutils literal notranslate"><span class="pre">b</span> <span class="pre">=</span> <span class="pre">tk.Button(root,</span> <span class="pre">text='button');</span> <span class="pre">b.pack()</span></code>. Again,
  909. nothing visibly changes in standard Python until one enters <code class="docutils literal notranslate"><span class="pre">root.update()</span></code>.</p>
  910. <p>Most tkinter programs run <code class="docutils literal notranslate"><span class="pre">root.mainloop()</span></code>, which usually does not
  911. return until the tk app is destroyed. If the program is run with
  912. <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-i</span></code> or from an IDLE editor, a <code class="docutils literal notranslate"><span class="pre">&gt;&gt;&gt;</span></code> shell prompt does not
  913. appear until <code class="docutils literal notranslate"><span class="pre">mainloop()</span></code> returns, at which time there is nothing left
  914. to interact with.</p>
  915. <p>When running a tkinter program from an IDLE editor, one can comment out
  916. the mainloop call. One then gets a shell prompt immediately and can
  917. interact with the live application. One just has to remember to
  918. re-enable the mainloop call when running in standard Python.</p>
  919. </section>
  920. <section id="running-without-a-subprocess">
  921. <h3>Running without a subprocess<a class="headerlink" href="#running-without-a-subprocess" title="Link to this heading">¶</a></h3>
  922. <p>By default, IDLE executes user code in a separate subprocess via a socket,
  923. which uses the internal loopback interface. This connection is not
  924. externally visible and no data is sent to or received from the internet.
  925. If firewall software complains anyway, you can ignore it.</p>
  926. <p>If the attempt to make the socket connection fails, Idle will notify you.
  927. Such failures are sometimes transient, but if persistent, the problem
  928. may be either a firewall blocking the connection or misconfiguration of
  929. a particular system. Until the problem is fixed, one can run Idle with
  930. the -n command line switch.</p>
  931. <p>If IDLE is started with the -n command line switch it will run in a
  932. single process and will not create the subprocess which runs the RPC
  933. Python execution server. This can be useful if Python cannot create
  934. the subprocess or the RPC socket interface on your platform. However,
  935. in this mode user code is not isolated from IDLE itself. Also, the
  936. environment is not restarted when Run/Run Module (F5) is selected. If
  937. your code has been modified, you must reload() the affected modules and
  938. re-import any specific items (e.g. from foo import baz) if the changes
  939. are to take effect. For these reasons, it is preferable to run IDLE
  940. with the default subprocess if at all possible.</p>
  941. <div class="deprecated">
  942. <p><span class="versionmodified deprecated">Deprecated since version 3.4.</span></p>
  943. </div>
  944. </section>
  945. </section>
  946. <section id="help-and-preferences">
  947. <h2>Help and Preferences<a class="headerlink" href="#help-and-preferences" title="Link to this heading">¶</a></h2>
  948. <section id="help-sources">
  949. <span id="id6"></span><h3>Help sources<a class="headerlink" href="#help-sources" title="Link to this heading">¶</a></h3>
  950. <p>Help menu entry “IDLE Help” displays a formatted html version of the
  951. IDLE chapter of the Library Reference. The result, in a read-only
  952. tkinter text window, is close to what one sees in a web browser.
  953. Navigate through the text with a mousewheel,
  954. the scrollbar, or up and down arrow keys held down.
  955. Or click the TOC (Table of Contents) button and select a section
  956. header in the opened box.</p>
  957. <p>Help menu entry “Python Docs” opens the extensive sources of help,
  958. including tutorials, available at <code class="docutils literal notranslate"><span class="pre">docs.python.org/x.y</span></code>, where ‘x.y’
  959. is the currently running Python version. If your system
  960. has an off-line copy of the docs (this may be an installation option),
  961. that will be opened instead.</p>
  962. <p>Selected URLs can be added or removed from the help menu at any time using the
  963. General tab of the Configure IDLE dialog.</p>
  964. </section>
  965. <section id="setting-preferences">
  966. <span id="preferences"></span><h3>Setting preferences<a class="headerlink" href="#setting-preferences" title="Link to this heading">¶</a></h3>
  967. <p>The font preferences, highlighting, keys, and general preferences can be
  968. changed via Configure IDLE on the Option menu.
  969. Non-default user settings are saved in a <code class="docutils literal notranslate"><span class="pre">.idlerc</span></code> directory in the user’s
  970. home directory. Problems caused by bad user configuration files are solved
  971. by editing or deleting one or more of the files in <code class="docutils literal notranslate"><span class="pre">.idlerc</span></code>.</p>
  972. <p>On the Font tab, see the text sample for the effect of font face and size
  973. on multiple characters in multiple languages. Edit the sample to add
  974. other characters of personal interest. Use the sample to select
  975. monospaced fonts. If particular characters have problems in Shell or an
  976. editor, add them to the top of the sample and try changing first size
  977. and then font.</p>
  978. <p>On the Highlights and Keys tab, select a built-in or custom color theme
  979. and key set. To use a newer built-in color theme or key set with older
  980. IDLEs, save it as a new custom theme or key set and it well be accessible
  981. to older IDLEs.</p>
  982. </section>
  983. <section id="idle-on-macos">
  984. <h3>IDLE on macOS<a class="headerlink" href="#idle-on-macos" title="Link to this heading">¶</a></h3>
  985. <p>Under System Preferences: Dock, one can set “Prefer tabs when opening
  986. documents” to “Always”. This setting is not compatible with the tk/tkinter
  987. GUI framework used by IDLE, and it breaks a few IDLE features.</p>
  988. </section>
  989. <section id="extensions">
  990. <h3>Extensions<a class="headerlink" href="#extensions" title="Link to this heading">¶</a></h3>
  991. <p>IDLE contains an extension facility. Preferences for extensions can be
  992. changed with the Extensions tab of the preferences dialog. See the
  993. beginning of config-extensions.def in the idlelib directory for further
  994. information. The only current default extension is zzdummy, an example
  995. also used for testing.</p>
  996. </section>
  997. </section>
  998. <section id="module-idlelib">
  999. <span id="idlelib"></span><h2>idlelib<a class="headerlink" href="#module-idlelib" title="Link to this heading">¶</a></h2>
  1000. <p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.12/Lib/idlelib">Lib/idlelib</a></p>
  1001. <hr class="docutils" />
  1002. <p>The Lib/idlelib package implements the IDLE application. See the rest
  1003. of this page for how to use IDLE.</p>
  1004. <p>The files in idlelib are described in idlelib/README.txt. Access it
  1005. either in idlelib or click Help =&gt; About IDLE on the IDLE menu. This
  1006. file also maps IDLE menu items to the code that implements the item.
  1007. Except for files listed under ‘Startup’, the idlelib code is ‘private’ in
  1008. sense that feature changes can be backported (see <span class="target" id="index-7"></span><a class="pep reference external" href="https://peps.python.org/pep-0434/"><strong>PEP 434</strong></a>).</p>
  1009. </section>
  1010. </section>
  1011. <div class="clearer"></div>
  1012. </div>
  1013. </div>
  1014. </div>
  1015. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  1016. <div class="sphinxsidebarwrapper">
  1017. <div>
  1018. <h3><a href="../contents.html">Table of Contents</a></h3>
  1019. <ul>
  1020. <li><a class="reference internal" href="#">IDLE</a><ul>
  1021. <li><a class="reference internal" href="#menus">Menus</a><ul>
  1022. <li><a class="reference internal" href="#file-menu-shell-and-editor">File menu (Shell and Editor)</a></li>
  1023. <li><a class="reference internal" href="#edit-menu-shell-and-editor">Edit menu (Shell and Editor)</a></li>
  1024. <li><a class="reference internal" href="#format-menu-editor-window-only">Format menu (Editor window only)</a></li>
  1025. <li><a class="reference internal" href="#run-menu-editor-window-only">Run menu (Editor window only)</a></li>
  1026. <li><a class="reference internal" href="#shell-menu-shell-window-only">Shell menu (Shell window only)</a></li>
  1027. <li><a class="reference internal" href="#debug-menu-shell-window-only">Debug menu (Shell window only)</a></li>
  1028. <li><a class="reference internal" href="#options-menu-shell-and-editor">Options menu (Shell and Editor)</a></li>
  1029. <li><a class="reference internal" href="#window-menu-shell-and-editor">Window menu (Shell and Editor)</a></li>
  1030. <li><a class="reference internal" href="#help-menu-shell-and-editor">Help menu (Shell and Editor)</a></li>
  1031. <li><a class="reference internal" href="#context-menus">Context menus</a></li>
  1032. </ul>
  1033. </li>
  1034. <li><a class="reference internal" href="#editing-and-navigation">Editing and Navigation</a><ul>
  1035. <li><a class="reference internal" href="#editor-windows">Editor windows</a></li>
  1036. <li><a class="reference internal" href="#key-bindings">Key bindings</a></li>
  1037. <li><a class="reference internal" href="#automatic-indentation">Automatic indentation</a></li>
  1038. <li><a class="reference internal" href="#search-and-replace">Search and Replace</a></li>
  1039. <li><a class="reference internal" href="#completions">Completions</a></li>
  1040. <li><a class="reference internal" href="#calltips">Calltips</a></li>
  1041. <li><a class="reference internal" href="#code-context">Code Context</a></li>
  1042. <li><a class="reference internal" href="#shell-window">Shell window</a></li>
  1043. <li><a class="reference internal" href="#text-colors">Text colors</a></li>
  1044. </ul>
  1045. </li>
  1046. <li><a class="reference internal" href="#startup-and-code-execution">Startup and Code Execution</a><ul>
  1047. <li><a class="reference internal" href="#command-line-usage">Command line usage</a></li>
  1048. <li><a class="reference internal" href="#startup-failure">Startup failure</a></li>
  1049. <li><a class="reference internal" href="#running-user-code">Running user code</a></li>
  1050. <li><a class="reference internal" href="#user-output-in-shell">User output in Shell</a></li>
  1051. <li><a class="reference internal" href="#developing-tkinter-applications">Developing tkinter applications</a></li>
  1052. <li><a class="reference internal" href="#running-without-a-subprocess">Running without a subprocess</a></li>
  1053. </ul>
  1054. </li>
  1055. <li><a class="reference internal" href="#help-and-preferences">Help and Preferences</a><ul>
  1056. <li><a class="reference internal" href="#help-sources">Help sources</a></li>
  1057. <li><a class="reference internal" href="#setting-preferences">Setting preferences</a></li>
  1058. <li><a class="reference internal" href="#idle-on-macos">IDLE on macOS</a></li>
  1059. <li><a class="reference internal" href="#extensions">Extensions</a></li>
  1060. </ul>
  1061. </li>
  1062. <li><a class="reference internal" href="#module-idlelib">idlelib</a></li>
  1063. </ul>
  1064. </li>
  1065. </ul>
  1066. </div>
  1067. <div>
  1068. <h4>Previous topic</h4>
  1069. <p class="topless"><a href="tkinter.tix.html"
  1070. title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.tix</span></code> — Extension widgets for Tk</a></p>
  1071. </div>
  1072. <div>
  1073. <h4>Next topic</h4>
  1074. <p class="topless"><a href="development.html"
  1075. title="next chapter">Development Tools</a></p>
  1076. </div>
  1077. <div role="note" aria-label="source link">
  1078. <h3>This Page</h3>
  1079. <ul class="this-page-menu">
  1080. <li><a href="../bugs.html">Report a Bug</a></li>
  1081. <li>
  1082. <a href="https://github.com/python/cpython/blob/main/Doc/library/idle.rst"
  1083. rel="nofollow">Show Source
  1084. </a>
  1085. </li>
  1086. </ul>
  1087. </div>
  1088. </div>
  1089. <div id="sidebarbutton" title="Collapse sidebar">
  1090. <span>«</span>
  1091. </div>
  1092. </div>
  1093. <div class="clearer"></div>
  1094. </div>
  1095. <div class="related" role="navigation" aria-label="related navigation">
  1096. <h3>Navigation</h3>
  1097. <ul>
  1098. <li class="right" style="margin-right: 10px">
  1099. <a href="../genindex.html" title="General Index"
  1100. >index</a></li>
  1101. <li class="right" >
  1102. <a href="../py-modindex.html" title="Python Module Index"
  1103. >modules</a> |</li>
  1104. <li class="right" >
  1105. <a href="development.html" title="Development Tools"
  1106. >next</a> |</li>
  1107. <li class="right" >
  1108. <a href="tkinter.tix.html" title="tkinter.tix — Extension widgets for Tk"
  1109. >previous</a> |</li>
  1110. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  1111. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  1112. <li class="switchers">
  1113. <div class="language_switcher_placeholder"></div>
  1114. <div class="version_switcher_placeholder"></div>
  1115. </li>
  1116. <li>
  1117. </li>
  1118. <li id="cpython-language-and-version">
  1119. <a href="../index.html">3.12.3 Documentation</a> &#187;
  1120. </li>
  1121. <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
  1122. <li class="nav-item nav-item-2"><a href="tk.html" >Graphical User Interfaces with Tk</a> &#187;</li>
  1123. <li class="nav-item nav-item-this"><a href="">IDLE</a></li>
  1124. <li class="right">
  1125. <div class="inline-search" role="search">
  1126. <form class="inline-search" action="../search.html" method="get">
  1127. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  1128. <input type="submit" value="Go" />
  1129. </form>
  1130. </div>
  1131. |
  1132. </li>
  1133. <li class="right">
  1134. <label class="theme-selector-label">
  1135. Theme
  1136. <select class="theme-selector" oninput="activateTheme(this.value)">
  1137. <option value="auto" selected>Auto</option>
  1138. <option value="light">Light</option>
  1139. <option value="dark">Dark</option>
  1140. </select>
  1141. </label> |</li>
  1142. </ul>
  1143. </div>
  1144. <div class="footer">
  1145. &copy;
  1146. <a href="../copyright.html">
  1147. Copyright
  1148. </a>
  1149. 2001-2024, Python Software Foundation.
  1150. <br />
  1151. This page is licensed under the Python Software Foundation License Version 2.
  1152. <br />
  1153. Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
  1154. <br />
  1155. See <a href="/license.html">History and License</a> for more information.<br />
  1156. <br />
  1157. The Python Software Foundation is a non-profit corporation.
  1158. <a href="https://www.python.org/psf/donations/">Please donate.</a>
  1159. <br />
  1160. <br />
  1161. Last updated on Apr 09, 2024 (13:47 UTC).
  1162. <a href="/bugs.html">Found a bug</a>?
  1163. <br />
  1164. Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.2.6.
  1165. </div>
  1166. </body>
  1167. </html>
上海开阖软件有限公司 沪ICP备12045867号-1