Had to use the label widget today and thought that it would look nicer with a coloured background and white text. But, the label has no background attribute, it simple places text over its container. So, to get a solid fill the label widget needs to be placed inside an eventBox. Ok, we shalln't need the all the functionality of this container but its the right choice. Now for the foreground colour. Again more confusion. The GtkLabel, infact, has no style properties so the text foregroud can't be set explicity either. It has to be achieved using Pango Markup.
FInally, anyone whose used the label will have noticed that the pango markup application didn't work properly with the -text option. Don't worrry, now that's fixed and will be included in the next upload.
Here's a sample script from the Tcler's wiki
FInally, anyone whose used the label will have noticed that the pango markup application didn't work properly with the -text option. Don't worrry, now that's fixed and will be included in the next upload.
Here's a sample script from the Tcler's wiki
#!/bin/sh
# the next line restarts using tclsh \
exec tclsh "$0" "$@"
package require Gnocl
set etitle "Tcl/Gnocl 8.5"
proc setString {angle} {
return "Angle = $angle degs"
}
set angle 330
set string [setString $angle]
set lab [gnocl::label -textVariable string \
-baseFont {Sans 30} \
-angle $angle]
set but [gnocl::button \
-icon "%#Refresh" \
-onClicked {
incr angle 15
if {$angle == "360" } {set angle 0}
set string [setString $angle]
$lab configure -angle $angle
}]
set box [gnocl::box -orientation vertical]
$box add $but
$box add $lab -fill {1 1} -expand 1
set win [gnocl::window -title $etitle \
-child $box \
-onDelete {exit} ]
gnocl::mainLoop
And here's a screenshot:
Comments