User interface 如何设置Tk小部件的默认字体
我有一个Tcl/Tk应用程序,可以生成许多表单,并且希望能够从中心位置配置默认的小部件字体,而不必使用User interface 如何设置Tk小部件的默认字体,user-interface,fonts,tcl,tk,User Interface,Fonts,Tcl,Tk,我有一个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] --- " #/希望 button.hello-文本“hel
-font
开关配置每个小部件
#!<path>/wish
button .hello -text "Hello, World!" -command { exit }
pack .hello
puts "--- i would like to set this thing: [.hello configure -font] --- "
#/希望
button.hello-文本“hello,World!”-命令{exit}
打包,你好
puts“---我想设置这个东西:[.hello configure-font]--”
尝试添加
font create myDefaultFont -family Helvetica -size 20
option add *font myDefaultFont
到脚本的顶部 这正是我想要的。谢谢如果您不熟悉Tk的命名字体概念,那么使用上面的方法可以在以后的运行时更改字体。您所需要做的就是重新配置myDefaultFont,使用该字体的每个小部件将立即使用新字体重新绘制自身。不需要手动迭代所有的小部件。看起来这篇文章已经消失了。回程机显示: