Copyright © 2008, 2009 Arndt Roger Schneider
Only the Rtl_mlistbox and Rtl_gridwin templates are affected by Tile. See: the section called “Rtl_mlistbox” and the section called “Rtl_gridwin”.
Tile is bundled with Tk 8.5. And Tile with Templates applies for this particular version, only.
Any Runtime Library based template supports a »-creator« property. The creator property can be used with a ttk::frame as its argument. The instance of that template then is created from a ttk::frame.
Critical missing Properties in Tile bundled with Tk 8.5
background
foreground
highlightThickness
highlightBackground
highlightColor
borderWidth
relief
Although, the Runtime Library is able to detect, when a Tile window is used, and silently ignores errors steming from the attempt to configure such a window. The retrieval however is a different part and requires either a fix of Tile –that it allows queries on such properties– or a workaround inside each template to remove the base properties from the interface and query the theme instead for their values.
Without either one, a template based window can not report what properties it actually has. The »configure« all message must fail for the window.
Example 2.2. Failed configure all
rtl_gridwin .gwin -creator ttk::frame # This must fail: .gwin configure # This must fail, too: .gwin cget -background # This succeeds, but only for non # Tile based elements: .gwin configure -background red
»cget« and »configure« are not affected as long as the property does not originate from the Tile window.
The template interface must be changed in order to allow proper property retrieval from themed elements. This can be done by replacing the first item inside property map table with special code which queries the theme instead of the window for the property in question.
Example 2.3. Inoculate the Template Interface against Tile
namespace eval rtl_gridwin { set var(background) \ [list tileBackground $var(background)]] proc set-tileBackground { base color } { # do nothing ... } proc get-tileBackground { base } { # retrieve the background from the theme. # and return it as color. return [ttk::style lookup frame -background] } } # Now the rtl_gridwin -background is # inoculated against Tile.
Any window belonging to the template interface will after Example 2.3, “Inoculate the Template Interface against Tile” partake in Tiles colour scheme –regardless of its origin from »tk::« or »ttk::«.
Example 2.5. ...Inoculate »pkgIndex.tcl«
# The template will monitor themes. bind Gistbox <<ThemeChanged>> { foreach _ { background highlightthickness borderwidth highlightbackground relief highlightcolor } { %W configure -$_ [%W cget -$_] } } } }
Example 2.7. Tcl/Tk 8.5 Combine Tile and Rtl_mlistbox
# package require tile; –not needed under 8.5. # Tell the multi-column-listbox to use a # Tk Label for its header row: option add *Rtl_mlistbox.label tk::label
Under Tcl/Tk 8.5 and higher, the tk label is imported into the Rtl_mlistbox namespace. The rescue operation Example 2.6, “Tcl/Tk 8.4 Combine Tile and Rtl_mlistbox” is thus only necessary for 8.4 and earlier Tcl/Tk releases.