TIP 776: Add tk_restorePalette Command

Login
Author:         Kevin Walzer([email protected])
State:          Draft
Type:           Project
Created:        15-Nov-2026
Tcl-Version:    9.2
Tk-Branch:      restore_palette
Keywords:       Tk, X11, dark mode, appearance
Vote:           Pending

Forum: 85c215e4fe

Post-History:

Abstract

With the increased interest in supporting dark mode and general system window appearance across platforms as outlined in TIP 750, a key tool in helping to implement this functionality is tk_setPalette. To integrate Tk's appearance with a dark-themed desktop, tk_setPalette black is a quick way to do this. However, tk_setPalette has historically been a one-way operation. tk_restorePalette provides a simple way to return Tk's palette to its default values, which fits in well if a desktop environment changes from a dark to a light theme.

Specification

The procedure tk_restorePalette undoes tk_setPalette: windows that still have a color the palette gave them get back the color they had before the first tk_setPalette call, and the option database is changed so that windows made later get the original defaults again. Windows whose colors the application has set itself since are left alone. It does nothing if tk_setPalette has not changed anything.

Reference Implementation

Branch restore_palette.

This document has been placed in the public domain.