TIP #154 Version 1.1: Add Named Colors to Tk

This is not necessarily the current version of this TIP.


TIP:154
Title:Add Named Colors to Tk
Version:$Revision: 1.1 $
Author:Damon Courtney <damon at unreality dot com>
State:Draft
Type:Project
Tcl-Version:8.5
Vote:Pending
Created:Wednesday, 03 September 2003

Abstract

This TIP proposes the addition of a color command at the Tk level to allow developers to create named colors as they can already do with both fonts and images.

Rationale

Named fonts and images go a long way toward making Tk able to modify a lot of options on a global scale simply by adjusting a single item. Tk already simulates some version of named colors on Windows with the use of values like SystemButtonFace and SystemWindowFrame. These color names map to values predefined in Windows. On UNIX, we have to kind of fake these things around.

With the addition of a color command, we can simply define default colors in UNIX that correspond to existing named colors on Windows. So, we could create SystemButtonFace as a named color on UNIX, and any Windows program using those color names would port to UNIX without a change (we may do this already. I haven't run Tk on UNIX in some time).

Implementation

I propose the introduction of a new command, color:

color <subcommand> ?arg ..?

To create a new named color in terms of an existing color (either named or in one of the #RGB formats), the create subcommand would be used:

color create <colorName> <color>

The currently defined named colors (including those defined by Tk) can be retrieved using the names subcommand:

color names

A named color can also be deleted using the delete subcommand:

color delete <colorName>

Author's Note

I have already managed to implement most of this command with just an hour of work. Most of that time was spent familiarizing myself with Tk's color code. Tk already has code at the C level to implement named colors. This TIP mostly just proposes exposing control of that layer at the Tk level.

Copyright

This document has been placed in the public domain.


Powered by TclThis is not necessarily the current version of this TIP.

TIP AutoGenerator - written by Donal K. Fellows