Version 0 of Tk Style Support

Updated 2003-08-04 22:24:23

TIP #48 [L1 ] provides an API to support alternative styles for Tk widgets.

This TIP was implemented in March 2002, but there is very little other than the TIP itself to document how this might be used and what further work is required.

The basis of the Tk style API is to break down the Tk widgets into elements. Elements abstract objects for which an implementation may be registered with a given style engine. A style name can be used to select a set of element implementations and thus provide an alternative look to the Tk widgets.

As the Tk code stands for 8.5a0, we have this styling API (in generic/tkStyle.c) but no elements. This makes the API pretty useless for now, so the first job is to implement a set of elements and rewrite the Tk widgets to do their drawing using elements. Once this is done, then it becomes simple to replace an element dynamically because of the design of the element search algorithm.

To illustrate we can take the Tk frame widget. We can decompose this into a highlight and a frame element. Now what we actually register is an element called 'highlight'. However, what we try to use is an element called 'Frame.highlight'. If this can't be found, then the element search algorithm trims off the first word and tries again until it runs out of bits. This permits us to provide a generic implementation, and then override it for specific widgets.

[more to come] ...