Showing posts from July, 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
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


Setting tree/list column header widget

Just added a new option to the gnocl::tree/gnocl::list columnConfigure sub-command to allow embedded widgets.

# test-columnWidget.tcl
exec tclsh "$0" "$@"

package require Gnocl

set tree [gnocl::tree \
    -types {string integer} \
    -titles {"" "# of Legs"}]

$tree add {} {Mamals Birds Bugs}
$tree add 0 {{Cat 4} {Dog 4} {Human 2}}

foreach {paro pred} [$tree add 1 {Parrots Predator}] {}

$tree add $paro {{Cockatoo 2} {Amazone 2}}
$tree add $pred {{Hawk 2} {Eagle 2}}

$tree expand \
    -path "1" \
    -recursive 1

gnocl::window \
    -title "Tree" \
    -child $tree \
    -defaultWidth 300 \

set but(1) [gnocl::button -text HIDIHI]
$tree columnConfigure 1 -widget $but(1)