| Ticket UUID: | a2125a1bc924cf988e154beeada2f53bfe6dfc10 | |||
| Title: | MS-Win: Title bar not dark in dark mode | |||
| Type: | RFE | Version: | main | |
| Submitter: | oehhar | Created on: | 2026-03-16 09:58:57 | |
| Subsystem: | 68. Win Window Operations | Assigned To: | oehhar | |
| Priority: | 5 Medium | Severity: | Minor | |
| Status: | Closed | Last Modified: | 2026-05-21 06:55:30 | |
| Resolution: | Fixed | Closed By: | oehhar | |
| Closed on: | 2026-05-21 06:55:30 | |||
| Description: |
Alexandru reported on clt: When WIndows is in dark mode, the wish title bar does not show-up in dark. Here is an information page about the issue: https://learn.microsoft.com/en-us/windows/apps/desktop/modernize/ui/apply-windows-themes Here is a solution by Eric:
proc apply_dark_titlebar {win} {
update idletasks
set hwnd [expr {[wm frame $win]}]
set ps_file "$::env(TEMP)/dark_titlebar.ps1"
set vbs_file "$::env(TEMP)/dark_titlebar.vbs"
set ps_script "\$v = 1
\$hwnd = \[IntPtr\]${hwnd}L
Add-Type @'
using System;
using System.Runtime.InteropServices;
public class DWM {
\[DllImport(\"dwmapi.dll\")\]
public static extern int DwmSetWindowAttribute(IntPtr h, int a, ref int v, int s);
}
'@
\[DWM\]::DwmSetWindowAttribute(\$hwnd, 19, \[ref\]\$v, 4)
"
set fh [open $ps_file w]
puts $fh $ps_script
close $fh
set ps_native [file nativename $ps_file]
set vbs_script "CreateObject(\"WScript.Shell\").Run \"powershell.exe -ExecutionPolicy Bypass -NonInteractive -WindowStyle Hidden -File \"\"$ps_native\"\"\", 0, True"
set fh [open $vbs_file w]
puts $fh $vbs_script
close $fh
catch { exec wscript.exe $vbs_file }
# Force DWM to recompose by withdrawing and re-showing
wm withdraw $win
wm deiconify $win
raise $win
focus $win
file delete $ps_file
file delete $vbs_file
}
if [catch {
package require awdark
::ttk::style theme use awdark
} err_code] {
puts $err_code
}
wm geom . 405x200+32+32
ttk::frame .f
ttk::button .f.b -text "Apply Dark Title" -command { apply_dark_titlebar . ;after 200 {console show}}
pack .f .f.b -fill x -expand true
It would be great to include this into Tk. THanks for all, Harald | |||
| User Comments: |
oehhar added on 2026-05-21 06:55:30:
TIP 750 implements this. Fixed by merge of TIP_750 branch with [92224a0d]. Thanks for all, Harald marc_culler (claiming to be Marc Culler) added on 2026-05-20 22:57:12: Hi Harald. I think we can close this ticket now. TIP 750 makes the title bar dark in dark mode. oehhar added on 2026-04-01 07:11:15: Windows top menu color bug info forwarded to ticket [11bd4a03]. So, this is only about the title bar which is an rfe and not a bug emiliano added on 2026-04-01 00:26:13: Re menubar background issue: besides the link Harald mentioned, here is a stack overflow question about this subject https://stackoverflow.com/questions/77985210/how-to-set-menu-bar-color-in-win32 I agree that this is a different bug oehhar added on 2026-03-31 16:07:18: Dear Emiliano, thanks for the extension. It works great! Here is the nmake makefile: PROJECT = darkmode PROJECT_REQUIRES_TK = 1 PRJ_LIBS = dwmapi.lib !include "rules-ext.vc" PRJ_OBJS = $(TMP_DIR)\darkmode.obj !include "targets.vc" pkgindex: default-pkgindex The standard cmd.exe console window uses this dark title even in light mode. This makes sense. Dark mode is an appication decission and may vary from Window to Window even in the same application. The color of the top menu bar is not changed: tk::unsupported::darkmode [wm frame .] 1 menu .m menu .m -bg black -fg white menu .m2 -bg black -fg white .m add cascade -menu .m2 -label Sub .m2 add command -label Cmd . configure -menu .m But the issue is more, that the configured color is not honored for the top bar, but for all other sub-menus. Here is a post in another project solving this: https://github.com/tauri-apps/muda/issues/97. This may be seen as a different bug. Thanks for all, Harald nab added on 2026-03-17 14:59:43: Hi, the great deal would be that embedded menu of toplevels that are sets to darkmode to be also in darkMode $topLevel configure -menu $myMenu ++ nicolas emiliano added on 2026-03-17 13:57:34: I've written a quick POC extension to set the title bar dark mode here. The usage is
I've not used the toplevel name directly because the attribute must be set on the wrapper window, and accessing it requires access to the private Tk API. If this were added to Tk, it could simply be
| |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki