| Ticket UUID: | 1c516561715500223cff9f425960e1fe98cb49c7 | |||
| Title: | tk_setPalette overrides colours the application set, and records the wrong defaults | |||
| Type: | Bug | Version: | 9.0.4, 9.1b1 | |
| Submitter: | serhiy.storchaka | Created on: | 2026-10-26 19:11:24 | |
| Subsystem: | 02. Appearance | Assigned To: | aku | |
| Priority: | 5 Medium | Severity: | Important | |
| Status: | Closed | Last Modified: | 2026-11-01 11:40:49 | |
| Resolution: | Fixed | Closed By: | nemethi | |
| Closed on: | 2026-11-01 11:40:49 | |||
| Description: |
::tk::RecolorTree, which tk_setPalette uses to recolour the windows which
already exist, changed in [2e0526a2d3] (2024-07-07, "Update palette.tcl")
and the change inverted it. Until then it was:
set chosencolor [lindex $value 4]
...
if {[string match $defaultcolor $chosencolor]} {
append result ";\noption add [list \
*[winfo class $w].$dbOption $c($dbOption) 60]"
$w configure $option $c($dbOption)
}
A window is recoloured only where it still has the colour Tk gave it, which
is what the documentation promises: "modifying all of the color options for
existing widgets that have the default value". The commit moved the
configure out of the condition, so that every window is recoloured, and
negated the condition, so that the option database is written in the
opposite case. Its new comment reads [lindex $value 4] as the colour being
requested; at that point it is still the colour the window has.
Two things follow, neither of them in 8.6.
A colour the application chose itself is overwritten:
frame .mine -background red
tk_setPalette #3c3c3c
.mine cget -background
;# 8.6.18: red 9.0, 9.1: #3c3c3c
And a third palette no longer reaches the windows made after it, because the
entry of class priority keeps the colour of the palette before it while
*background at widgetDefault holds the new one:
tk_setPalette #3c3c3c ; tk_setPalette #d9d9d9 ; tk_setPalette #3c3c3c
frame .p ; .p cget -background
;# 8.6.18: #3c3c3c 9.0, 9.1: #d9d9d9
So a palette which is switched back and forth, as a light one and a dark one
are, leaves the windows made before and after a switch disagreeing.
Proposed fix in branch tk-setpalette-recolor, which puts the condition back
and names the value it tests for what it holds. There were no tests for
tk_setPalette; the branch adds tests/palette.test with one for each half.
| |||
| User Comments: |
nemethi (claiming to be Csaba Nemethi) added on 2026-11-01 11:40:49:
Serhiy, many thanks for the bugfix! Merged into main and core-9-0-branch by commits [5bd4ff0c] and [5689c12e]. The bug was present in Tk 9 only, hence no backport to core-8-6-branch is needed. | |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki