[WJG] (23/11/08) One of the many enhanced formatting features of Gtk widgets is the use of the Pango Text Markup Language for text formatting [http://library.gnome.org/devel/pango/unstable/PangoMarkupFormat.html]. Whilst this isn't a feature that the developer will want to use with every label it has its uses when colour or font effects are desirable. Here's a brief sample derived from a recent posting of Tk code taken from the Tcl newsgroup. ---- [http://wjgiddings.googlepages.com/pangoTML.png] ---- And here's to code to produce this: #!/bin/sh # the next line restarts using tclsh \ exec tclsh "$0" "$@" package require Gnocl set etitle "Tcl/Tk 8.5" proc nullcmd {} { global type puts -nonewline "8.5 " puts $type } #1) create buttons, format strings with markup code set lab [gnocl::label -text {%<RADIOBUTTONS } ] set rb1 [gnocl::radioButton -text {%<serial } -variable type -onValue "serial" -onToggled nullcmd] set rb2 [gnocl::radioButton -text {%<-non-Serial } -variable type -onValue "newnonser" -onToggled nullcmd] set rb3 [gnocl::radioButton -text {%<cross-Ref } -variable type -onValue "crossref" -onToggled nullcmd] set rb4 [gnocl::radioButton -text {%<CODEN Only } -variable type -onValue "codenonly" -onToggled nullcmd] set cb1 [gnocl::checkButton -text {%<CheckButton } ] #2) create container and add the buttons set box [gnocl::box -orientation vertical] $box add [list $lab $rb1 $rb2 $rb3 $rb4 $cb1 ] #3) create toplevel and add the widgets in one drop set win [gnocl::window -title $etitle -child $box -onDelete {exit} ] gnocl::mainLoop ---- By way of comparison, here's a screengrab of the layout that the Tk code posted produced running on my Linux box, mmm... very retro... [http://wjgiddings.googlepages.com/tkSample.png] [ZB] Were there any problems with using Ttk (instead of "ordinary" Tk)? [WJG] (24/11/08) Problems,no. The Tk script ran smoothly. The Gtk libraries now offer more resources than Tk so, if someone is developing new apps or utilities running on Linux boxes, why not use these instead? [ZB] So, actually, why did you compare "look & feel" of GTK-widgets with oldest Tk, as if there were no Ttk? It's not fair comparison. [WJG] Of course its a fair comparison. This is the native look and feel of Tk. From where I stand, Ttk is a 'band-aid'. [DKF]: The interesting things to compare here are not that the capabilities are different, but rather that the gnome engine can do this by embedded markup fragments rather than options. [WJG]: Exactly, this is the point. Gtk has more to offer. Use Tcl packages to harness new resources, fashionable resources, rather that staying with the past. I take your semantic argument that markup strings are not command options, but in pragmatic terms they are because they offer the scripter more choice, more options to choose from. [ZB]: And what's wrong with options, that you prefer "embedded markup fragments"? [WJG]: They're not my cup of tea, but its a part of Gtk. Here's a sample that I'm sure is not possible with a tk '''label'''. [http://wjgiddings.googlepages.com/Screenshot-PangoTML.png] Here's the code to make that label: #!/bin/sh # the next line restarts using tclsh \ exec tclsh "$0" "$@" package require Gnocl set lab [gnocl::label -text {%<Hello World2}] set win [gnocl::window -title "Pango TML" -child $lab -onDelete {exit} ] gnocl::mainLoop [DKF]: OTOH, Tk's good at handling other things, such as tying a label to a variable with the `-textvariable` option. I'm not claiming superiority of one over the other. (The idea of full [HTML] in a label seems odd to me, or at least “flow” part of HTML, but that's possibly just me.) [WJG] Y'know, I think that under the bonnet Tk is good, so much has grown out of it, Gtk for instance owes a lot to Tk. ---- [WJG] (24/11/08) Here's some wild stuff that I think many people would be interested in '''arbitrarily rotated''' text with '''full-antialiasing''' and the use of a '''-textVariable''' option for labels which again has been rendered with Pango Markup Language. I've seen this sort of thing discussed on the wiki using Tk and images but use system resources whenever possible, why re-invent the wheel? Note: The gnocl::label '''-angle''' and '''-textVariable''' options are still developmental and will available in the next release of Gnocl but if anyone is eager to try them now, I'd be more than happy to email them the current label.c source code. [http://wjgiddings.googlepages.com/Screenshot-Tcl-Gnocl8.5SpinLabel.png] And here's the Gnocl script: #!/bin/sh # the next line restarts using tclsh \ exec tclsh "$0" "$@" package require Gnocl set angle 0 set string "Angle = 0 degs" proc setString {angle} { return "Angle = $angle degs" } set lab [gnocl::label -textVariable string -baseFont {Sans 30}] 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 [list $but $lab ] set win [gnocl::window -title "Tcl/Gnocl 8.5" -child $box -onDelete {exit} ] gnocl::mainLoop1 ---- !!!!!! %| [Category GUI] |% !!!!!!