Ttk带有18个小部件,其中12个已经存在于tkinter中: Button, Checkbutton, Entry, Frame, Label, LabelFrame, Menubutton, PanedWindow, Radiobutton, Scale, ScrollbarSpinbox 。其他六个是新的: Combobox, Notebook, Progressbar, Separator, SizegripTreeview。它们都是 Widget 的子类。

    使用Ttk小部件可以改善应用程序的外观和感觉。如上所述,样式的编码方式存在差异。
    Tk的代码:

    1. l1 = tkinter.Label(text="Test", fg="black", bg="white")
    2. l2 = tkinter.Label(text="Test", fg="black", bg="white")

    Ttk的代码:

    1. style = ttk.Style()
    2. style.configure("BW.TLabel", foreground="black", background="white")
    3. l1 = ttk.Label(text="Test", style="BW.TLabel")
    4. l2 = ttk.Label(text="Test", style="BW.TLabel")

    有关TtkStyling的更多信息,请参见Style类文档。