IDLE 用户界面——IDLE启动细节

未匹配的标注

大多数读者应该能立即使用IDLE,因为它是当今 Mac OS X 和大多数Linux 安装过程的一个标准组件,且它在Windows上被自动地和标准Python 安装到一起。然而,因为平台各异,需要在打开这个GUI前给出一些指引。

技术上讲,IDLE是一个使用标准库的 tkinter(在Python 2.X中名为 Tkinter) GUI 工具包来构建其窗口的Python程序。这让IDLE可移植——在所有主流桌面平台上工作一致——但也意外着需要在Python中得到tkinter的支持来使用IDLE。这个支持在Windows,Macs和Linux上是标准的,但在一些系统上,它附带一些注意事项,且在各平台上启动可以有差异。下面是一些平台特别的提示:

  • On Windows 7 and earlier, IDLE is easy to start—it’s always present after a Python install, and has an entry in the Start button menu for Python in Windows 7 and earlier (see Figure 2-1, shown previously). You can also select it by right-clicking on a Python program icon, and launch it by clicking on the icon for the files idle.pyw or idle.py located in the idlelib subdirectory of Python’s Lib directory. In this mode, IDLE is a clickable Python script that lives in C:\Python33\Lib\idlelib, C:\Python27\Lib\idlelib, or similar, which you can drag out to a shortcut for one-click access if desired.

  • On Windows 8, look for IDLE in your Start tiles, by a search for “idle,” by browsing your “All apps” Start screen display, or by using File Explorer to find the idle.py file mentioned earlier. You may want a shortcut here, as you have no Start button menu in desktop mode (at least today; see Appendix A for more pointers).

  • Mac OS X 上IDLE需要的所有东西都作为操作系统的标准组件存在。IDLE应该在 MacPython(或 Python N.M) 程序文件夹下面的 Applications 中可以启动。这里注意:由于稳定版本依赖,一些 OS X版本可能需要安装更新的 tkinter 支持(这里就不对读者介绍这么复杂的东西了);参见 python.org 的下载页获取详情。

  • Linux上,当前IDLE通常也是作为一个标准组件存在。它可能采用在你路径中的一个 idle 可执行文件或脚本的形式;在shell中输入它来检查。在一些机器上,它可能需要安装(参见附录A获取指示),且在其他系统上可能需要从命令行或图标点击来启动IDLE的顶层脚本:运行在Python的 /usr/lib目录中的 idlelib子目录中的idle.py(运行 find 来找到确切的位置)

因为 IDLE 只是在标准库中的模块搜索路径上的一个Python脚本,还可以在任何平台,任何目录在系统命令shell窗口通过输入下面的语句来运行它(比如在Windows上的命令提示符),然而这将需要参见附录A和 Part V 来获取关于 Python的 -m标记 和 这里需要的“.”包语法的更多知识(在本书的这个节点上盲目的信任就足够了):

c:\code> python -m idlelib.idle # Run idle.py in a package on module path

要获取更多关于在Windows和其他平台的安装问题和使用的注意事项,确保参考附录A和Python标准手册中的“Python设置和用法”中关于你的平台的注意事项。

本文章首发在 LearnKu.com 网站上。

上一篇 下一篇
讨论数量: 0
发起讨论 只看当前版本


暂无话题~