Version 1 of gnocl::fixed

Updated 2010-05-21 10:56:09 by WJG

WJG (21/05/10) Althouhg Gnocl has implemented a wide range of containers one noticable area of functionality has been missing, the ability to specifically locate and resize a widget within its parent. The forthcoming release of gnocl will have a number of new items in its range of widget, one being gnocl::fixed, the bindings around the GtkFixed widget. Examination of the Gtk documentation largely discourages the use of this widget because Gnome users may, unlike their Windows and MacOSX cousins, use all sorts of different themes suited to either personal preference of visual impairment and so the dynamic resizing of widgets is widely promoted. On the other hand, experience Tk coders may prefer the use of the place command. With this caveat in mind, Tcl/Gnocl coders will soon be able to position widget directly to enable more 'creative' layouts.

Here's a screen shot of the current test script:

http://lh3.ggpht.com/_yaFgKvuZ36o/S_ZhNF4YaaI/AAAAAAAAArQ/T4QGX35KK1A/s800/Screenshot-test_fixed.tcl.png

And here's the script:

# basic Tcl/Gnocl Script
#!/bin/sh \
exec tclsh "$0" "$@"
package require Gnocl


set but(1) 10
set but(2) 30
set but(3) 50
set but(4) 70

set but1 [gnocl::button -text "APPLE"]
set but2 [gnocl::button -text "BANNANA"]
set but3 [gnocl::button -text "CHERRY"]
set but4 [gnocl::button -text "DAMSON"]

set fx [gnocl::fixed -label TEST -background red]
gnocl::window -child $fx -width 200 -height 130

$fx add $but1  -x $but(1) -y 10 -width 80 -height 40
$fx add $but2  -x $but(2) -y 30 -width 80 -height 40
$fx add $but3  -x $but(3) -y 50 -width 80 -height 40
$fx add $but4  -x $but(4) -y 70 -width 80 -height 40


$but1 configure -onClicked {
        if {$but(1) == 10} {set but(1) 110} else {set but(1) 10}
        $fx move %w  -x $but(1) -y 10 -width 80 -height 40
}

$but2 configure -onClicked {
        if {$but(2) == 30} {set but(2) 110} else {set but(2) 30}
        $fx move %w  -x $but(2) -y 30 -width 80 -height 40
}

$but3 configure -onClicked {
        if {$but(3) == 50} {set but(3) 110} else {set but(3) 50}
        $fx move %w  -x $but(3) -y 50 -width 80 -height 40
}

$but4 configure -onClicked {
        if {$but(4) == 70} {set but(4) 110} else {set but(4) 70}
        $fx move %w  -x $but(4) -y 70 -width 80 -height 40
}

gnocl::mainLoop