The aim of this project is to apply the Mica effect and enable immersive dark mode on python applications made with Python, like Tkinter, PyQt/PySide, WxPython, Kivy, etc.
This will work on any windows version, including the new released dev builds where the mica API is public.
View this project on PyPi View this project on GitHub
https://github.com/marticliment/win32mica/assets/53119851/b0c4ce98-9845-449d-94e6-caaa37fc752a
python -m pip install win32mica
darkdetect
module######################################################################
# #
# Those examples are oversimplified, please see the examples/ folder #
# for detailed usage with each UI library. #
# #
######################################################################
hwnd = window.winId().__int__() # Get the hWnd of your window
from win32mica import ApplyMica, MicaTheme, MicaStyle
mode = MicaTheme.DARK # Dark mode mica effect
mode = MicaTheme.LIGHT # Light mode mica effect
mode = MicaTheme.AUTO # Apply system theme, and change it if system theme changes
style = MicaStyle.DEFAULT # Default backdrop effect
style = MicaStyle.ALT # Alt backdrop effect
def callbackFunction(NewTheme):
if newTheme == MicaTheme.DARK:
print("Theme has changed to dark!")
else:
print("Theme has changed to light!")
win32mica.ApplyMica(HWND=hwnd, Theme=mode, Style=style, OnThemeChange=callbackFunction)
# Parameters
# ----------
# HWND : int
# The handle to the window on which the effect has to be applied
# Theme : MicaTheme, int
# The theme of the backdrop effect: MicaTheme.DARK, MicaTheme.LIGHT, MicaTheme.AUTO
# Style : MicaStyle, int
# The style of the mica backdrop effect: MicaStyle.DEFAULT, MicaStyle.ALT
# OnThemeChange : function
# A callback function that receives one parameter to call when the system theme changes (will only work if Theme is set to MicaTheme.AUTO)
# The passed parameter will be either MicaTheme.DARK or MicaTheme.LIGHT, corresponding to the new system theme
You can check out the examples folder for detailed use in Tk and PySide/PyQt.
Those are PySide2 windows with custom widgets.