fr Application wide font size variation as common in browsers, key combination control plus/minus. This works on named fonts, especially the default widget fonts. Minimum value is used to avoid reversing effect on negative size values.
proc fontresize {i} {
if {$i>0} {
foreach f [font names] {
set fs [font configure $f -size]
if {[expr {$fs>20}]} {
return -code break
}
}
} else {
foreach f [font names] {
set fs [font configure $f -size]
if {[expr {$fs<3}]} {
return -code break
}
}
}
foreach f [font names] {
set fs [font configure $f -size]
incr fs $i
font configure $f -size $fs
}
}
proc test {} {
package require Tk
bind . "<Control-plus>" {fontresize 1}
bind . "<Control-minus>" {fontresize -1}
entry .e -textvariable ::z
set ::z input
label .l -text label
text .t -height 2 -width 40
.t insert end "press control-+ or control-minus\nto adjust global font size"
pack .e .l .t
toplevel .k
label .k.l -text another\ child-window
listbox .k.f -listvariable ::f
set ::f [font names]
pack .k.l .k.f
focus .
}
testJH Note that tklib style::as provides this via style::as::enable control-mousewheel local|global