Skip to content

Instantly share code, notes, and snippets.

@Olikonsti
Last active March 23, 2024 23:41
Show Gist options
  • Save Olikonsti/879edbf69b801d8519bf25e804cec0aa to your computer and use it in GitHub Desktop.
Save Olikonsti/879edbf69b801d8519bf25e804cec0aa to your computer and use it in GitHub Desktop.
import ctypes as ct
def dark_title_bar(window):
"""
MORE INFO:
https://docs.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute
"""
window.update()
DWMWA_USE_IMMERSIVE_DARK_MODE = 20
set_window_attribute = ct.windll.dwmapi.DwmSetWindowAttribute
get_parent = ct.windll.user32.GetParent
hwnd = get_parent(window.winfo_id())
rendering_policy = DWMWA_USE_IMMERSIVE_DARK_MODE
value = 2
value = ct.c_int(value)
set_window_attribute(hwnd, rendering_policy, ct.byref(value), ct.sizeof(value))
@tomlin7
Copy link

tomlin7 commented Jul 1, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment