TIP #186: Expose the Type and Modified-State of Widget Options


TIP:186
Title:Expose the Type and Modified-State of Widget Options
Version:$Revision: 1.4 $
Authors: Peter MacDonald <pmacdona at pdqi dot com>
Peter MacDonald <peter at pdqi dot com>
State:Draft
Type:Project
Tcl-Version:8.7
Vote:Pending
Created:Friday, 16 April 2004
Keywords:Tk

Abstract

This TIP adds a 6th (and 7th element) to each option in the output of [path configure] for Tk widgets, indicating the type and modified status of each option respectively.

Rationale

The configure subcommand of Tk widgets provides a powerful method for introspection of widget state information. Unfortunately, two important pieces of information are currently unavailable. Namely, the type Tk is expecting for an option and the whether a user has explicitly assigned a value.

The type field is valuable in automating interfaces for editing the contents of widgets.

The modified field is useful in changing styles (such as in tk_setPalette) where we update all widgets that are currently using default values.

Specification

The configure subcommand for Tk widgets, when invoked with no arguments, currently dumps out all options as a list with 5 elements per-option: optName, dbName, dbClass, defValue, optValue. This TIP proposes adding up to 2 additional values: optType and optModified.

Notes

Perhaps optModified should be specified as an enumeration. For example:

In addition, as much of the Tk core is still using Tk_ConfigSpec, would some form of compatibility interface make sense whereby a Tk_ConfigSpec could be used to dynamically produce a Tk_OptionSpec? (This last is out of the scope of this TIP.)

Probably also need a way to change options such that the USER_MODIFIED flag does not get set. (eg. tk_setPalette)

Changes

Threre are a couple of small changes to tkConfig.c and tkOldConfig.c, plus a #define of TK_OPTION_VALUE_SET in tk.h

Overhead/Impact

Scripts currently exploiting introspection and depending upon a list length of 5 may break.

Reference Implementation

There is a simple implementation of the above available as a patch against Tk 8.4.2[1]. It does not implement a enumerated flag for optModified, and the type string lookup is rather crude.

Copyright

This document has been placed in the public domain.


Powered by Tcl[Index] [History] [Edit] [HTML Format] [Source Format] [LaTeX Format] [Text Format] [XML Format] [*roff Format (experimental)] [RTF Format (experimental)]

TIP AutoGenerator - written by Donal K. Fellows