WJG (23/11/08) One of the many enhanced formatting features of Gtk widgets is the use of the Pango for text formatting[L1 ]. Whilst this isn't a feature that the developer will want to use 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.
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 {%<<span background = "springgreen2"><b>RADIOBUTTONS </b></span>} ] set rb1 [gnocl::radioButton -text {%<<span background = "palegreen1">serial </span>} -variable type -onValue "serial" -onToggled nullcmd] set rb2 [gnocl::radioButton -text {%<<span background = "palegreen1">-non-Serial </span>} -variable type -onValue "newnonser" -onToggled nullcmd] set rb3 [gnocl::radioButton -text {%<<span background = "palegreen1">cross-Ref </span>} -variable type -onValue "crossref" -onToggled nullcmd] set rb4 [gnocl::radioButton -text {%<<span background = "palegreen1">CODEN Only </span>} -variable type -onValue "codenonly" -onToggled nullcmd] set cb1 [gnocl::checkButton -text {%<<span background = "palegreen1">CheckButton </span>} ] #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... ZB Were there any problems with using Ttk (instead of "ordinary" Tk)? WJG (24/11/08) Problems,no. The Tk script ran smoothly.
enter categories here |
---|