Tk themed widgets通过Tkinter.ttk模块管理 和使用。
Tkinter有两个版本的widgets:
老的传统的 tk
组合,1991年的版本就有了。- 新的
ttk组件是在
2007 的Tk 8.5中添加. ttk widgets可以替换很多的tk widgets.
ttk
表示 Tk themed.
1、ttk和tk模块调用的例子
调用 tk和ttk模块:
import tkinter as tk
from tkinter import ttk
import tkinter as tk
from tkinter import ttk
root = tk.Tk()
tk.Label(root, text='Classic Label').pack()
ttk.Label(root, text='Themed Label').pack()
root.mainloop()
2、ttk模块有什么优势呢?
- Separating the widget’s behavior and appearance – the ttk widgets attempt to separate the code that implements the widgets’ behaviors from their appearance through the styling system..
- Native look & feel – the ttk widgets have the native look and feel of the platform on which the program runs.
- Simplify