Apply mica background to Windows 11 Win32 apps made with python
Project description
Win32mica (aka PyMica): A simple module to add the Mica effect on legacy python windows
The aim of this project is to apply the Mica effect 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
Installation:
python -m pip install win32mica
Requirements:
- Windows 11
- A window set to not have a transparent background and to have extended composition enabled* (It might work with other settings, but nothing is guaranteed.)
- The HWND (identifier) of that window. More info: what is a hwnd?
- OPTIONAL: The window must have semi-transparent widgets/controls in order to recreate the transparency effect on the controls.
- OPTIONAL: Know if Windows has dark or light mode enabled. This can be checked with the
darkdetect
module
Usage:
hwnd = qtwindow.winId().__int__() # On a PyQt/PySide window
hwnd = tkwindow.frame() # On a tkinter window
# You'll need to adjust this to your program
from win32mica import MICAMODE, ApplyMica
mode = MICAMODE.DARK # Dark mode mica effect
mode = MICAMODE.LIGHT # Light mode mica effect
# Choose one of them following your app color scheme
import darkdetect # Auto mode detect
mode = darkdetect.isDark()
win32mica.ApplyMica(hwnd, mode)
Result:
This is a PySide2 window with custom transparent widgets. The screenshot has been taken on dark mode.
- A window with transparent background means a window where the background widget is transparent. The window must also have, in the case of Qt, those flags enabled:
qtwindow.setAttribute(Qt.WA_TranslucentBackground)
if QtWin.isCompositionEnabled():
QtWin.extendFrameIntoClientArea(qtwindow, -1, -1, -1, -1)
else:
QtWin.resetExtendedFrame(qtwindow)
Other approaches might need to be made for other GUI toolkits to work
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
win32mica-1.4.tar.gz
(4.4 kB
view hashes)