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


No comments: