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.

301 lines
7.0 KiB

Merged revisions 70342,70385-70387,70389-70390,70392-70393,70395,70400,70405-70406,70418,70438,70464,70468 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r70342 | georg.brandl | 2009-03-13 14:03:58 -0500 (Fri, 13 Mar 2009) | 1 line #5486: typos. ........ r70385 | benjamin.peterson | 2009-03-15 09:38:55 -0500 (Sun, 15 Mar 2009) | 1 line fix tuple.index() error message #5495 ........ r70386 | georg.brandl | 2009-03-15 16:32:06 -0500 (Sun, 15 Mar 2009) | 1 line #5496: fix docstring of lookup(). ........ r70387 | georg.brandl | 2009-03-15 16:37:16 -0500 (Sun, 15 Mar 2009) | 1 line #5493: clarify __nonzero__ docs. ........ r70389 | georg.brandl | 2009-03-15 16:43:38 -0500 (Sun, 15 Mar 2009) | 1 line Fix a small nit in the error message if bool() falls back on __len__ and it returns the wrong type: it would tell the user that __nonzero__ should return bool or int. ........ r70390 | georg.brandl | 2009-03-15 16:44:43 -0500 (Sun, 15 Mar 2009) | 1 line #5491: clarify nested() semantics. ........ r70392 | georg.brandl | 2009-03-15 16:46:00 -0500 (Sun, 15 Mar 2009) | 1 line #5488: add missing struct member. ........ r70393 | georg.brandl | 2009-03-15 16:47:42 -0500 (Sun, 15 Mar 2009) | 1 line #5478: fix copy-paste oversight in function signature. ........ r70395 | georg.brandl | 2009-03-15 16:51:48 -0500 (Sun, 15 Mar 2009) | 1 line #5276: document IDLESTARTUP and .Idle.py. ........ r70400 | georg.brandl | 2009-03-15 16:59:37 -0500 (Sun, 15 Mar 2009) | 3 lines Fix markup in re docs and give a mail address in regex howto, so that the recommendation to send suggestions to the author can be followed. ........ r70405 | georg.brandl | 2009-03-15 17:11:07 -0500 (Sun, 15 Mar 2009) | 7 lines Move the previously local import of threading to module level. This is cleaner and avoids lockups in obscure cases where a Queue is instantiated while the import lock is already held by another thread. OKed by Tim Peters. ........ r70406 | hirokazu.yamamoto | 2009-03-15 17:43:14 -0500 (Sun, 15 Mar 2009) | 1 line Added skip for old MSVC. ........ r70418 | georg.brandl | 2009-03-16 14:42:03 -0500 (Mon, 16 Mar 2009) | 1 line Add token markup. ........ r70438 | benjamin.peterson | 2009-03-17 15:29:51 -0500 (Tue, 17 Mar 2009) | 1 line I thought this was begging for an example ........ r70464 | benjamin.peterson | 2009-03-18 15:58:09 -0500 (Wed, 18 Mar 2009) | 1 line a much better example ........ r70468 | benjamin.peterson | 2009-03-18 22:04:31 -0500 (Wed, 18 Mar 2009) | 1 line close files after comparing them ........
18 years ago
  1. .. _idle:
  2. IDLE
  3. ====
  4. .. moduleauthor:: Guido van Rossum <guido@Python.org>
  5. .. index::
  6. single: IDLE
  7. single: Python Editor
  8. single: Integrated Development Environment
  9. IDLE is the Python IDE built with the :mod:`tkinter` GUI toolkit.
  10. IDLE has the following features:
  11. * coded in 100% pure Python, using the :mod:`tkinter` GUI toolkit
  12. * cross-platform: works on Windows and Unix
  13. * multi-window text editor with multiple undo, Python colorizing and many other
  14. features, e.g. smart indent and call tips
  15. * Python shell window (a.k.a. interactive interpreter)
  16. * debugger (not complete, but you can set breakpoints, view and step)
  17. Menus
  18. -----
  19. File menu
  20. ^^^^^^^^^
  21. New window
  22. create a new editing window
  23. Open...
  24. open an existing file
  25. Open module...
  26. open an existing module (searches sys.path)
  27. Class browser
  28. show classes and methods in current file
  29. Path browser
  30. show sys.path directories, modules, classes and methods
  31. .. index::
  32. single: Class browser
  33. single: Path browser
  34. Save
  35. save current window to the associated file (unsaved windows have a \* before and
  36. after the window title)
  37. Save As...
  38. save current window to new file, which becomes the associated file
  39. Save Copy As...
  40. save current window to different file without changing the associated file
  41. Close
  42. close current window (asks to save if unsaved)
  43. Exit
  44. close all windows and quit IDLE (asks to save if unsaved)
  45. Edit menu
  46. ^^^^^^^^^
  47. Undo
  48. Undo last change to current window (max 1000 changes)
  49. Redo
  50. Redo last undone change to current window
  51. Cut
  52. Copy selection into system-wide clipboard; then delete selection
  53. Copy
  54. Copy selection into system-wide clipboard
  55. Paste
  56. Insert system-wide clipboard into window
  57. Select All
  58. Select the entire contents of the edit buffer
  59. Find...
  60. Open a search dialog box with many options
  61. Find again
  62. Repeat last search
  63. Find selection
  64. Search for the string in the selection
  65. Find in Files...
  66. Open a search dialog box for searching files
  67. Replace...
  68. Open a search-and-replace dialog box
  69. Go to line
  70. Ask for a line number and show that line
  71. Indent region
  72. Shift selected lines right 4 spaces
  73. Dedent region
  74. Shift selected lines left 4 spaces
  75. Comment out region
  76. Insert ## in front of selected lines
  77. Uncomment region
  78. Remove leading # or ## from selected lines
  79. Tabify region
  80. Turns *leading* stretches of spaces into tabs
  81. Untabify region
  82. Turn *all* tabs into the right number of spaces
  83. Expand word
  84. Expand the word you have typed to match another word in the same buffer; repeat
  85. to get a different expansion
  86. Format Paragraph
  87. Reformat the current blank-line-separated paragraph
  88. Import module
  89. Import or reload the current module
  90. Run script
  91. Execute the current file in the __main__ namespace
  92. .. index::
  93. single: Import module
  94. single: Run script
  95. Windows menu
  96. ^^^^^^^^^^^^
  97. Zoom Height
  98. toggles the window between normal size (24x80) and maximum height.
  99. The rest of this menu lists the names of all open windows; select one to bring
  100. it to the foreground (deiconifying it if necessary).
  101. Debug menu (in the Python Shell window only)
  102. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  103. Go to file/line
  104. look around the insert point for a filename and linenumber, open the file, and
  105. show the line.
  106. Open stack viewer
  107. show the stack traceback of the last exception
  108. Debugger toggle
  109. Run commands in the shell under the debugger
  110. JIT Stack viewer toggle
  111. Open stack viewer on traceback
  112. .. index::
  113. single: stack viewer
  114. single: debugger
  115. Basic editing and navigation
  116. ----------------------------
  117. * :kbd:`Backspace` deletes to the left; :kbd:`Del` deletes to the right
  118. * Arrow keys and :kbd:`Page Up`/:kbd:`Page Down` to move around
  119. * :kbd:`Home`/:kbd:`End` go to begin/end of line
  120. * :kbd:`C-Home`/:kbd:`C-End` go to begin/end of file
  121. * Some :program:`Emacs` bindings may also work, including :kbd:`C-B`,
  122. :kbd:`C-P`, :kbd:`C-A`, :kbd:`C-E`, :kbd:`C-D`, :kbd:`C-L`
  123. Automatic indentation
  124. ^^^^^^^^^^^^^^^^^^^^^
  125. After a block-opening statement, the next line is indented by 4 spaces (in the
  126. Python Shell window by one tab). After certain keywords (break, return etc.)
  127. the next line is dedented. In leading indentation, :kbd:`Backspace` deletes up
  128. to 4 spaces if they are there. :kbd:`Tab` inserts 1-4 spaces (in the Python
  129. Shell window one tab). See also the indent/dedent region commands in the edit
  130. menu.
  131. Python Shell window
  132. ^^^^^^^^^^^^^^^^^^^
  133. * :kbd:`C-C` interrupts executing command
  134. * :kbd:`C-D` sends end-of-file; closes window if typed at a ``>>>`` prompt
  135. * :kbd:`Alt-p` retrieves previous command matching what you have typed
  136. * :kbd:`Alt-n` retrieves next
  137. * :kbd:`Return` while on any previous command retrieves that command
  138. * :kbd:`Alt-/` (Expand word) is also useful here
  139. .. index:: single: indentation
  140. Syntax colors
  141. -------------
  142. The coloring is applied in a background "thread," so you may occasionally see
  143. uncolorized text. To change the color scheme, edit the ``[Colors]`` section in
  144. :file:`config.txt`.
  145. Python syntax colors:
  146. Keywords
  147. orange
  148. Strings
  149. green
  150. Comments
  151. red
  152. Definitions
  153. blue
  154. Shell colors:
  155. Console output
  156. brown
  157. stdout
  158. blue
  159. stderr
  160. dark green
  161. stdin
  162. black
  163. Startup
  164. -------
  165. Upon startup with the ``-s`` option, IDLE will execute the file referenced by
  166. the environment variables :envvar:`IDLESTARTUP` or :envvar:`PYTHONSTARTUP`.
  167. Idle first checks for ``IDLESTARTUP``; if ``IDLESTARTUP`` is present the file
  168. referenced is run. If ``IDLESTARTUP`` is not present, Idle checks for
  169. ``PYTHONSTARTUP``. Files referenced by these environment variables are
  170. convenient places to store functions that are used frequently from the Idle
  171. shell, or for executing import statements to import common modules.
  172. In addition, ``Tk`` also loads a startup file if it is present. Note that the
  173. Tk file is loaded unconditionally. This additional file is ``.Idle.py`` and is
  174. looked for in the user's home directory. Statements in this file will be
  175. executed in the Tk namespace, so this file is not useful for importing functions
  176. to be used from Idle's Python shell.
  177. Command line usage
  178. ^^^^^^^^^^^^^^^^^^
  179. ::
  180. idle.py [-c command] [-d] [-e] [-s] [-t title] [arg] ...
  181. -c command run this command
  182. -d enable debugger
  183. -e edit mode; arguments are files to be edited
  184. -s run $IDLESTARTUP or $PYTHONSTARTUP first
  185. -t title set title of shell window
  186. If there are arguments:
  187. #. If ``-e`` is used, arguments are files opened for editing and
  188. ``sys.argv`` reflects the arguments passed to IDLE itself.
  189. #. Otherwise, if ``-c`` is used, all arguments are placed in
  190. ``sys.argv[1:...]``, with ``sys.argv[0]`` set to ``'-c'``.
  191. #. Otherwise, if neither ``-e`` nor ``-c`` is used, the first
  192. argument is a script which is executed with the remaining arguments in
  193. ``sys.argv[1:...]`` and ``sys.argv[0]`` set to the script name. If the script
  194. name is '-', no script is executed but an interactive Python session is started;
  195. the arguments are still available in ``sys.argv``.