What's Tkinter?
The Tkinter module (“Tk interface”) is the standard Python interface to the Tk GUI toolkit from Scriptics (formerly developed by Sun Labs).
TKinter 模块是 Tk GUI 套件的标准Python接口。
Both Tk and Tkinter are available on most Unix platforms, as well as on Windows and Macintosh systems. Starting with the 8.0 release, Tk offers native look and feel on all platforms.
TK和Tkinter在大多数 Unix平台、Windows平台和Macintosh系统都可以使用,从8.0版本开始,Tk在所有的平台上提供原生的界面外观。
Tkinter consists of a number of modules. The Tk interface is provided by a binary extension module named _tkinter. This module contains the low-level interface to Tk, and should never be used directly by application programmers. It is usually a shared library (or DLL), but might in some cases be statically linked with the Python interpreter.
Tkinter 包含了大量的模块。Tk接口是由一个叫做_tkinter的二进制扩展模块提供。这个模块包含Tk的底层接口,但是这些接口不能直接被应用程序所使用。它通常是一个共享库(或者动态链接库),在某些情况下可以被Python的解释器以静态链接的形式使用。
The public interface is provided through a number of Python modules. The most important interface module is the Tkinter module itself. To use Tkinter, all you need to do is to import the Tkinter module:
公共接口是通过一系列的Python模块提供的,最重要的接口就是Tkinter模块本身。想要使用Tkinter,所需要就是导入Tkinter模块:
import Tkinter
Or, more often:
或者:
from Tkinter import *
The Tkinter module only exports widget classes and associated constants, so you can safely use the from-in form in most cases. If you prefer not to, but still want to save some typing, you can use import-as:
大多数情况下使用from-in的格式可以安全的使用Tkinter模块,因为Tkinter模块仅仅导入了组件类和相关常量。如果不想这样做但又想少敲打一些字符,可以使用import-as:
import Tkinter as Tk