基本用法是
from Tkinter import *
從Python 2.4起,可以支援以下兩種內容
class Tkinter.Tk(screenName=None, baseName=None, className='Tk', useTk=1)
Tk class 並沒有參數. 通常用上述語法來建立一個Tk的最上層widget, 一般是程式的主視窗。各instance 都有它自用的Tcl解譯器。
從Python 2.4加入useTk 參數.
Tkinter.Tcl(screenName=None, baseName=None, className='Tk', useTk=0)
Tcl() 函式用來建立物件,很像透過Tk class所建立的,除了它不會設定Tk次系統。這在不想或不能(如Unix/Linux內沒有X Windows時)建立額外頂層視窗時,用來驅使Tcl解譯器非常好用。透過Tcl()元件建立的元件可以透過呼叫它的loadtk()方式來建立頂層視窗(並設定Tk次系統)。
其他提供 Tk 支援的模組有:
ScrolledText--帶有垂直捲動軸的文字widget。
tkColorChooser--讓使用者選擇顏色的對話框。
tkCommonDialog
Base class for the dialogs defined in the other modules listed here.
tkFileDialog
Common dialogs to allow the user to specify a file to open or save.
tkFont
Utilities to help work with fonts.
tkMessageBox
Access to standard Tk dialog boxes.
tkSimpleDialog
Basic dialogs and convenience functions.
Tkdnd
Drag-and-drop support for Tkinter. This is experimental and should become deprecated when it is replaced with the Tk DND.
turtle
Turtle graphics in a Tk window.
These have been renamed as well in Python 3.0; they were all made submodules of the new tkinter package.
沒有留言:
張貼留言