Configuring and Reconfiguring Attributes

When the widget is created or reconfigured, then the implementation needs to allocate the resources implied by the attribute settings. Each clock widget uses some colors and a font. These are described by graphics contexts that parameterize operations. Instead of specifying every possible attribute in graphics calls, a graphics context is initialized with a subset of the parameters, and this is passed into the graphic commands. The context can specify the foreground and background colors, clip masks, line styles, and so on. The clock widget allocates a graphics context once and reuses it each time the widget is displayed.

There are two kinds of color resources used by the widget. The focus highlight and ...

Get Practical Programming in Tcl & Tk, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.