Monday, May 27, 2013

gnocl::label cget

Fixed bug that appeared in the label widget cget subcommand after the move over to using LabelParams in the source code. At the moment cget -text returns the text without markup. Next step is to test for markup and return markup string if applicable.

Wednesday, May 15, 2013

gnocl::box remove command debugged

Problems with the remove child command resolved. This will be more useful when toggling the display of UI items. If the -visible option is used to manipulate object, space will still be allocated for the hidden object. This may be acceptable at times, but in large, complex layouts hiding already packed widgets may alter the overall window sizing or affect the relative sizing of other containers such as the gnocl::paned widget.

Test script:

#!/bin/sh
# the next line restarts using tclsh \
exec tclsh "$0" "$@"

package require Gnocl

proc swap_parent {w} {
    global box
   
    set p [$w parent]
    if {$p eq $box(1)} {
        $box(1) remove $w
        $box(2) add $w -fill {1 1} -expand 1
    } else {
        $box(2) remove $w
        $box(1) add $w -fill {1 1} -expand 1
    }
}
 

set box(1) [gnocl::box]
set box(2) [gnocl::box]

set win(1) [gnocl::window -title "Window #1" -x 100 -child $box(1) -width 200 -height 100]
set win(2) [gnocl::window -title "Window #2" -x 400 -child $box(2)  -width 200 -height 100]


set but(1) [gnocl::button -text "Click-Me!" -onClicked {swap_parent %w}]

$box(1) add $but(1) -fill {1 1} -expand 1


Tuesday, May 14, 2013

gnocl::label new options -background and -foreground

Spent a couple of hours today hacking this feature together. Ordinarily the base colour of a label is defined by the system style and can be overidden. Alternatively, it's possible to use markup strings. But... what if the text is set through a traced variable?
It is possible to modify the default pango settings for the label and modify these during runtime. It was fiddly to implement but now it works. To achieve similar result in the past required embedding the label into an eventBox.

Here's some demo code...


#!/bin/sh
# the next line restarts using tclsh \
exec tclsh "$0" "$@"

package require Gnocl

set lab [gnocl::label -text hello -baseFont {Sans 25} -foreground white -background blue]
set box [gnocl::eventBox -child $lab -background red]
gnocl::window -child $box -setSize 0.125