我正在使用 Tkinter 在 Python2.7 中开发 GUI,但我遇到了一个烦人的问题。
如果可能的话,我想定义所有小部件使用的默认字体。此行仅修改 Entry 或 ComboBox 中使用的字体:
root.option_add("*Font", "courier 10")
但不是例如复选框的标签。
我发现预定义的字体存在“TkDefaultFont”,但我无法更改其配置:
print tkFont.Font(font='TkDefaultFont').configure()
tkFont.Font(font='TkDefaultFont').config(family='Helvetica', size=20)
tk.TkDefaultFont = tkFont.Font(family="Helvetica",size=36,weight="bold")
print tkFont.Font(font='TkDefaultFont').configure()
返回 :
{'family': 'DejaVu Sans', 'weight': 'normal', 'slant': 'roman', 'overstrike': 0, 'underline': 0, 'size': -12} {'family': 'DejaVu Sans', 'weight': 'normal', 'slant': 'roman', 'overstrike': 0, 'underline': 0, 'size': -12}
(没有错误,但没有任何改变!!)
我做错了什么?