Improving the Package

   

Practical Programming in Tcl & Tk, Third Edition
By Brent B. Welch

Table of Contents
Chapter 42.  Managing User Preferences


One small improvement can be made to Pref_Add. If a user specifies a boolean resource manually, he or she might use "true" instead of one and "false" instead of zero. Pref_Add should check for those cases and set the boolean variable to one or zero to avoid errors when the variables are used in expressions.

The interface lets you dismiss it without saving your preference settings. This is either a feature that lets users try out settings without committing to them, or it is a bug. Fixing this requires introducing a parallel set of variables to shadow the real variables until the user hits Save, which is tedious to implement. You can also use a grab as described in Chapter 36 to prevent the user from doing anything but setting preferences.

This preference package is a slightly simplified version of one I developed for exmh, which has so many preference items that a two-level scheme is necessary. The first level is a menu of preference sections, and each section is created with a single call to Pref_Add. This requires additional arguments to Pref_Add to provide a title for the section and some overall information about the preference section. The display code changes a small amount. The code for the exmh is on the CD-ROM.


       
    Top
     



    Practical Programming in Tcl and Tk
    Practical Programming in Tcl and Tk (4th Edition)
    ISBN: 0130385603
    EAN: 2147483647
    Year: 1999
    Pages: 478

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net