如何设置Tk小部件的默认字体

5 user-interface fonts tk-toolkit tcl

我有一个生成许多表单的Tcl/Tk应用程序,并且希望能够从中央位置配置默认小部件字体,而无需使用-font交换机配置每个小部件.

#!<path>/wish
button .hello -text "Hello, World!" -command { exit }
pack .hello
puts "--- i would like to set this thing: [.hello configure -font] --- "
Run Code Online (Sandbox Code Playgroud)

Dyl*_*lan 10

尝试添加,

font create myDefaultFont -family Helvetica -size 20
option add *font myDefaultFont
Run Code Online (Sandbox Code Playgroud)

到你的脚本的顶部.(链接到字体上的文章)