【发布时间】:2015-10-06 18:33:50
【问题描述】:
尝试更改 Checkbutton 的样式,我只是好奇是否可以更改框本身的大小?
这是我目前所拥有的。在配置部分尝试了“高度”和“宽度”,但似乎没有成功。
s = ttk.Style()
s.theme_use('default')
s.configure("cbutton.TCheckbutton", foreground='#ebebeb', background='#5c5c5c', font=("arial", 14))
s.theme_settings("default",
{"TCheckbutton": {
"configure": {"padding": 5},
"map": {
"background": [("active", "#5C5C5C"),("!disabled", "#5C5C5C")],
"fieldbackground": [("!disabled", "#5C5C5C")],
"foreground": [("focus", "lightgray"),("!disabled", "lightgray")], "indicatorcolor": [('selected','#9ac947'),('pressed','#9ac947')]
}
}
})
这可能吗?
谢谢!
【问题讨论】:
-
我不确定,但我不这么认为。我浏览了在线文档和“Tcl and the Tk Toolkit”第二版,但找不到任何看起来像调整复选框本身大小的东西。
-
正如您在 [文档]tcl.tk/man/tcl8.5/TkCmd/ttk_checkbutton.htm#M10 中所读到的,宽度和高度用于指定可用于 Checkbutton 小部件文本的空间。不幸的是,您无法对 Checkbutton 样式进行任何操作来直接放大它。您可以通过自己创建一个新的 Checkbutton 小部件(例如基于 Frame 或 Button 小部件)来模仿它,并将背景图像设置为空的或选中的 checkbutton 图像来实现这一点。
-
很高兴知道——谢谢!
标签: python python-3.x tkinter ttk