The widgets in the Tk package have the really nifty sub-command cget which enables the settings for widget options to be extracted. Implementation of cget functionality within Gnocl is patchy for the most part as in most cases custom code needs to be added to extract settings. I've just added cget -baseFont for the text widget. This means that simple text zooming can be implemented in conjunction with the -onScroll option.
#---------------
# text widget zoom
#---------------
# arguments
# w text widget id
# d direction of scroll, ie up or down.
# s state of keytboard modifiers, must be Ctrl+scroll to run.
# returns
# nil
proc TextZoom {w d s} {
if { [$w class] != "text" } { return -1 }
set fnt "[$w cget -baseFont]"
set fsize [lindex $fnt 1]
if {$s != 4} { return }
switch $d {
up { incr fsize 2 }
down {incr fsize -2 }
}
lset fnt 1 $fsize
eval $w configure -baseFont [list $fnt]
}
Tuesday, September 18, 2012
Subscribe to:
Posts (Atom)
-
Given this module some attention today. Added some of the more package wide options to the module and created customised handler for settin...
-
Over the past few programming sessions I've been working on producing a central point, a dashboard, around which it's possible to se...
-
The contents of a GtkTextBuffer can be saved as serialized binary file. Whilst converting such a file to ascii may be problematic if the bu...