yawttk是用于tile的python包装器。它提供的类允许显示、定位和控制本机外观小部件。
yawTtk的Python项目详细描述
ttkwidget类是yawttk包的核心。它装载瓷砖和 覆盖配置功能以管理小部件选项和样式 选项。
支持此项目
-
3jgib9sqidlyml7qkbytjukhq2nyg6z63d
延伸
yawttk小部件扩展了ttkwidget,并且可以配置为 如果扩展选项为true,则为Tkinter小部件。有两种方法 禁用此功能:
>>> # for all widgets >>> customize_all_widgets(False) >>> # or >>> # for a single widget on its creation >>> button = Button(extend = False, text = "Simple button")
配置
在tile中,小部件选项和样式是分开的。Yawttk将它们合并到 尽量简化和匹配tkinter编码方式。记住它是 只有当extend选项为true时才可用。调用配置函数 通过init和setattr类方法,有3个 配置小部件的不同方法。
>>> # configure widget with __init__ function >>> button = Button( ... style = "custom.Toolbutton", ... anchor = "center", ... font = ("Tahoma", "8", "bold"), ... ) >>> # or with __setattr__ function >>> button["foreground"] = "steelblue3" >>> button["background"] = "lightgreen" >>> # or even with configure function >>> button.configure( ... command = exit, ... text = "Toolbutton", ... padding = (5, 1, 5, 1) ... ) >>> # pack and see... >>> button.pack(fill = "x", padx = 5, pady = 5)
在本例中,明确定义了小部件样式。如果不是的话 根据小部件类型和名称给出一个。下一个例子显示了不同的 yawttk风格确定的可能性。注意那个名字 由于Tkinter中的自动命名,因此不需要选项。
>>> b1 = Button(extend = False, text = "Button 1", name = "button001") >>> # style widget is "TButton" >>> b2 = Button(extend = False, text = "Button 2", name = "button002", style = "custom.TButton") >>> # style widget is "custom.TButton" >>> b3 = Button(extend = True, text = "Button 3", name = "button003") >>> # style widget is "button003.TButton" >>> b4 = Button(extend = True, text = "Button 4", name = "button004", style = "TButton") >>> # style widget is "TButton"
- b1和b2只能使用ttk::style configure命令配置
- b3和b4可以使用setattr进行自我配置并配置功能
- b1和b4是默认按钮,即修改会影响所有按钮
限制
tile(或tk 8.5)中定义了许多主题。赢家和专家 不允许对所有小部件选项进行修改。请看下面的示例:
>>> # other way to configure widget is to give a dictionary... >>> cnf = dict( ... # relief is not supported in "xpnative" and "winnative" theme ... relief = "solid", ... # options supported by all theme ... anchor = "center", ... font = ("Tahoma", "8", "bold"), ... foreground = "steelblue3", ... background = "lightgreen", ... command = exit, ... text = "Flat button", ... padding = (5, 1, 5, 1) ... )
对于每个互动程序主题:
>>> Button(None, cnf).pack(fill = "x", padx = 5, pady = 5)
Windows主题:
其他主题: