Thursday, July 05, 2012

gnocl::label new options

Just added two new options to the label widget, -mnemonicText and -mnemonicWidget. Whilst these titles are straight from the GtkWidget api, perhaps they need renaming before adding to the distribution. Basically, these options allow fields to be accessed using quick keyboard routes. Something that has been lacking to date. Here's the script that I'm experimenting with:

#---------------
# test-mnemonic.tcl
#---------------
#!/bin/sh
#\
exec tclsh "$0" "$@"

package require Gnocl


proc labelEntry {str var} {
    upvar $var v
    set box [gnocl::box]
    set ent [gnocl::entry -sizeGroup a]
    set lab [gnocl::label -align right -widthGroup aa -mnemonicText $str -mnemonicWidget $ent]
    $box add $lab
    $box add $ent
    return $box
}

set str(1) PRAJNA
set str(2) KARUNA
set str(3) MAITRI

set box [gnocl::box -orientation vertical]

$box add [labelEntry _Prajna str(1)]
$box add [labelEntry _Karuna str(2)]
$box add [labelEntry _Maitri str(3)]

gnocl::window -child $box -setSize 0.125


And, the screenshot:




No comments: