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

Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2017 Conference, Houston/TX, US, Oct 16-20
Send your abstracts to tclconference@googlegroups.com
by Aug 21.
Author:         Peter MacDonald <pmacdona@pdqi.com>
Author:         Peter MacDonald <peter@pdqi.com>
State:          Draft
Type:           Project
Vote:           Pending
Created:        16-Apr-2004
Keywords:       Tk
Tcl-Version:    8.7


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.


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.


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.


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)


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


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.2http://pdqi.com/configure.diff.gz . It does not implement a enumerated flag for optModified, and the type string lookup is rather crude.


This document has been placed in the public domain.