tags:

views:

485

answers:

1

I have 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.

#!/wish

button .hello -text "Hello, World!" -command { exit }

pack .hello

puts "--- i would like to set this thing: [.hello configure -font] --- "

+3  A: 

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
Thats exactly what I was looking for. Thanks!
wibaxter
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