I want to make the title bar of a toplevel window dark.no. I think it isn't.
Is this possible?
I couldn't find a solution in the toplevel and wm commands.
no. I think it isn't.In Windows I use a dark theme.
The title bar is what is called 'decoration' in the docs and it is
provided by the window manager.
However, if you choose a dark theme you shoukd get a 'dark' title bar. Whether that blends wit the rest of your toplevel is another question.
HTH
Helmut
Am 14.03.2026 um 16:24 schrieb Helmut Giese:Sorry, I have absolutely no experience with themes.
no. I think it isn't.In Windows I use a dark theme.
The title bar is what is called 'decoration' in the docs and it is
provided by the window manager.
However, if you choose a dark theme you shoukd get a 'dark' title bar.
Whether that blends wit the rest of your toplevel is another question.
HTH
Helmut
But somehow Tcl/Tk does not care about it.
Other programs automatically switch to a dark color of their title bars.
So maybe I shouldn't search for a command.
Instead Tcl/Tk should be fixed in that regard?Hm, instead of thinking that Tk is at fault I would continue
Hm, instead of thinking that Tk is at fault I would continueI'm already using the awtheme.
searching. How about looking for themed Tk apps (on the wiki?) and
learning from them?
HTH
Helmut
Am 14.03.2026 um 21:25 schrieb Helmut Giese:
Hm, instead of thinking that Tk is at fault I would continueI'm already using the awtheme.
searching. How about looking for themed Tk apps (on the wiki?) and
learning from them?
HTH
Helmut
It does not change the color of the title bar.
Here is written how to enable it:Thanks Harald, but I guess this solution is way to complicated for me
https://learn.microsoft.com/en-us/windows/apps/desktop/modernize/ui/ apply-windows-themes
File a ticket in Tk and perhaps somewone will work on the fix.
AFAI you refuse to touch the C code, so you depend on the grace of
others 😉.
Take care,
Harald
Am 15.03.2026 um 13:26 schrieb Harald Oehlmann:
Here is written how to enable it:Thanks Harald, but I guess this solution is way to complicated for me and my knowledge level.
https://learn.microsoft.com/en-us/windows/apps/desktop/modernize/ui/ apply-windows-themes
File a ticket in Tk and perhaps somewone will work on the fix.
AFAI you refuse to touch the C code, so you depend on the grace of others 😉.
Take care,
Harald
I might post a ticket then.
Regards
Alex
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
How badly do you want this? 🙂Not that bad :)
I got an AI to create a truly ugly script that can do this on my windows
10 system. It uses powershell and wscript. The wscript isn't actually needed, and cmd.exe can be used, but then you end up with a brief flash
of the cmd window.
Also, when the window has focus, it will still show the titlebar with
the normal window color, blue in my system. It will be dark only when another window has focus.
Here is the ticket:Thank you!
https://core.tcl-lang.org/tk/info/a2125a1bc924cf98
| Sysop: | DaiTengu |
|---|---|
| Location: | Appleton, WI |
| Users: | 1,105 |
| Nodes: | 10 (0 / 10) |
| Uptime: | 492344:34:50 |
| Calls: | 14,158 |
| Calls today: | 2 |
| Files: | 186,284 |
| D/L today: |
2,079 files (823M bytes) |
| Messages: | 2,502,674 |