6

I have a Tcl/Tk app that generates many forms and would like to be able to configure the default widget fonts from a central location without having to configure each widget with the -font switch.

#!<path>/wish
button .hello -text "Hello, World!" -command { exit }
pack .hello
puts "--- i would like to set this thing: [.hello configure -font] --- "
Jerry
  • 70,495
  • 13
  • 100
  • 144

1 Answers1

13

Try adding,

font create myDefaultFont -family Helvetica -size 20
option add *font myDefaultFont

to the top of your script. (link to article on fonts)

Dylan
  • 838
  • 1
  • 7
  • 13
  • if you are unfamiliar with Tk's notion of named fonts, using the above makes it trivial to change the font later at runtime. All you need to do is reconfigure myDefaultFont and every widget that uses that font will instantly redraw itself using the new font. No need to manually iterate over all the widgets. – Bryan Oakley May 10 '09 at 18:26
  • Looks like the article has vanished. Wayback Machine says: http://web.archive.org/web/20090302082049/http://www.tclscripting.com/articles/jun06/article1.html – jarodeells May 13 '14 at 22:17