Author: Serhiy Storchaka <[email protected]>
State: Draft
Type: Project
Created: 26-Oct-2026
Tcl-Version: 9.1
Tk-Branch: x11-appearance
Keywords: Tk, X11, dark mode, appearance
Vote: Pending
Forum: f5190c07ff
Post-History:
Abstract
TIP 750 left wm attributes window -appearance and winfo isdark
unimplemented on X11: there the attribute is rejected as a bad attribute, and
the command always returns false. This TIP implements both in terms of the
colours Tk itself uses, which is the only appearance an X11 window has.
Following the desktop's colour scheme is left to TIP 767.
Rationale
On macOS a window carries an NSAppearance and on Windows the window manager
answers for it. X11 has no such notion; what an X11 window has is the colour
it is painted.
That colour can already be dark. A desktop or user who wants dark
applications says so in the X resource database, and Tk has always honoured
it: with *background: #2e3436 and *foreground: #eeeeec in effect, the
classic and the ttk widgets both come up dark, unaided. KDE shipped
exactly this for years. So winfo isdark answering false on X11 is not a
statement that the platform has no dark mode; it is a wrong answer, and an
application that wants a readable colour must make the test by hand, as Tk's
widget demo does.
Answering from the window's colour differs in kind from the other platforms, where the system is asked. The alternative is to keep answering false until a desktop can be asked, as TIP 767 does, but an X11 window with a dark background is dark whether or not a desktop admits to it.
Ticket [807b2f8916], which completes the palette a dark background yields, is a prerequisite.
Specification
winfo isdarkwindow
On X11 this returns true when tk_setPalette would choose a white foreground for window's background, and false when it would choose a black one. The window need not be mapped. This replaces TIP 750's "On the Linux platform, this command always returns false."
wm attributeswindow-appearance ?light|dark|auto?
The attribute is added on X11, where it is at present rejected. light
and dark set Tk's palette to a light or a dark one, as tk_setPalette
sets it, save that the selection colours are left as they are: an accent
is not a shade of the frame. The palette overrides the colours the user
chose in X resources: an application setting the attribute has asked for
one explicitly.
auto is the default, and means the palette Tk derived at start-up from
the option database, light or dark according to the user's X resources.
Setting it restores that palette. With no value the attribute returns the
value last set, auto until one is set.
The palette is the application's, not the window's, the option database having no per-window scope: setting the attribute on any window sets the appearance of the application.
The appearance events of TIP 750 report a change of system settings, of which X11 has none to report until TIP 767, and are not sent here.
Reference Implementation
Branch x11-appearance. winfo isdark is answered from the window's
background pixel, and the attribute is implemented over tk_setPalette.
Compatibility
winfo isdark returns true on X11 for a window with a dark background. Code which branches on it takes the other branch there, which is the point; code relying on the false was relying on the feature's absence.
wm attributes window -appearance stops raising an error on X11. No
application can be setting the attribute there today, so none can depend on
what it does.
No colour of any existing application changes: the default auto is the
palette Tk has always started with.
Copyright
This document has been placed in the public domain.
