What's Tkinter? 什麼是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