Options for the Tk option database
In
Effective Tcl makes good reading
Effective Tcl/Tk Programming is good reading for any Tk user, including those who rely on PerlTk and Tkinter. Last month we recommended John Grayson's book on Tkinter to anyone scripting graphical user interfaces, whatever the toolkit. Although Grayson's examples are exclusively in Python, his design principles transcend any particular language. Similarly, Harrison and McLennan communicate coding ideas that you'll find useful no matter what language you're using. For example, their presentation of Tk correctly emphasizes the power and flexibility of the built-in canvas and text widgets.
Effective Tcl/Tk Programming also gives a clear exposition on the use of a script as a configuration file to be evaluated. Sections 4.7.8, "Saving a Drawing," and 7.6.6.3, "Using Tcl Commands to Express Data," explore the notion that "Tcl commands are a powerful way of expressing data." Our last column gave several other examples showing that this holds true for commands in any scripting language.
Another strength of Harrison and McLennan's book is its presentation in chapter 7 of the event-based programming style that we've covered in past Regular Expressions columns.
Back to (optional) work
Recall from the first two installments of this series that Tk uses the option command for all actions taken against the option database. We've already looked at the option add and option readfile subcommands. In this column, we'll explain option clear and option get.
option clear resets all assignments made to the option database by previous option add or option readfile commands. The idea is to return to a fresh wish process, one initialized only with the platform-specific resource database values. Tk implements this by dropping all values, and, at the time of the next use of the resource database, re-reading the external ~/.Xdefaults. This can surprise newcomers. An example helps: if .Xdefaults in your home directory contains the line:
*Button.background: cyan
and you run the script:
Essential JavaFX
Get started building rich Web apps quickly with an introduction to the power of JavaFX key features -- scene node graphs, nodes as components, the coordinate system, layout options, colors and gradients, custom classes with inheritance, animation, binding, and event handlers.Enter now!
The Nomadic Developer
Consulting can be hugely rewarding, but it's easy to fail if you are unprepared. To succeed, you need a mentor who knows the lay of the land. Aaron Erickson is your mentor, and this is your guidebook. Enter now!












