Match title bar color to dark theme on Windows (#948)
This commit is contained in:
1 parent
3b98b4b02c
commit
226cf3ff8f
1 file changed
+30
@@ -2391,6 +2391,28 @@ class GUIManager:
|
|||||||
# print to our custom output
|
# print to our custom output
|
||||||
self.output.print(message)
|
self.output.print(message)
|
||||||
|
|
||||||
|
def _set_title_bar_color(self, color: int) -> None:
|
||||||
|
"""
|
||||||
|
Set the Windows title bar color to match the theme.
|
||||||
|
Only works on Windows with DWM enabled.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
color: ARGB color value (e.g., 0x001E1E1E for dark gray).
|
||||||
|
"""
|
||||||
|
if sys.platform != "win32":
|
||||||
|
return
|
||||||
|
# DWMWA_CAPTION_COLOR = 35
|
||||||
|
DWMWA_CAPTION_COLOR = 35
|
||||||
|
hwnd = self._root.winfo_id()
|
||||||
|
frame_hwnd = ctypes.windll.user32.GetParent(hwnd)
|
||||||
|
color_value = ctypes.c_int(color)
|
||||||
|
ctypes.windll.dwmapi.DwmSetWindowAttribute(
|
||||||
|
frame_hwnd,
|
||||||
|
DWMWA_CAPTION_COLOR,
|
||||||
|
ctypes.byref(color_value),
|
||||||
|
ctypes.sizeof(ctypes.c_int),
|
||||||
|
)
|
||||||
|
|
||||||
def apply_theme(self, dark: bool) -> None:
|
def apply_theme(self, dark: bool) -> None:
|
||||||
"""
|
"""
|
||||||
Apply dark/light palette to ttk styles and Tk widgets in a minimal, non-invasive way.
|
Apply dark/light palette to ttk styles and Tk widgets in a minimal, non-invasive way.
|
||||||
@@ -2579,6 +2601,14 @@ class GUIManager:
|
|||||||
):
|
):
|
||||||
self._root.option_add(key, sel_fg)
|
self._root.option_add(key, sel_fg)
|
||||||
|
|
||||||
|
# Set Windows title bar color to match dark theme
|
||||||
|
if dark:
|
||||||
|
# Use dark gray color 0x001E1E1E (ARGB format, matches bg color #1e1e1e)
|
||||||
|
self._set_title_bar_color(0x001E1E1E)
|
||||||
|
else:
|
||||||
|
# Reset to system default title bar color
|
||||||
|
self._set_title_bar_color(0xFFFFFFFF)
|
||||||
|
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# GUI MANAGER END #
|
# GUI MANAGER END #
|
||||||
|
|||||||
Reference in new issue
Block a user