Skip to main content

Win32mica: A simple module to add the Mica effect and enable immersive dark mode on Python UI Windows

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

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:

######################################################################
#                                                                    #
# 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.

Result:

image
image

Those are PySide2 windows with custom widgets.

Release files for win32mica 3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for win32mica 3.0
File Size Uploaded
win32mica-3.0.tar.gz 5.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for win32mica 3.0
File Interpreter ABI Platform
win32mica-3.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.5 kB

Release files / win32mica-3.0.tar.gz

Download URL win32mica-3.0.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
87dcbd7d098bc9e778bd7035a81831ddd952e37ac7eafbc82105fc316a629945
BLAKE2b-256 checksum
How to use checksums
9c918aecf60b274ac4192f88ded4b4f6c9b3ed4868eecc845b5479b49337dc92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / win32mica-3.0-py3-none-any.whl

Download URL win32mica-3.0-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8e4c0454f886aad095197adfcc24c58bc83b5f26bb951c461dc1509448600b9d
BLAKE2b-256 checksum
How to use checksums
4437fe689f99ebaf08c082fd0fce61f38b92d88b047e9270d58f4f04caae9a0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release history Release notifications | RSS feed

This release

3.0 This release

2 release files

2.0

2 release files

1.9

2 release files

1.8

2 release files

1.7

2 release files

1.6

2 release files

1.5

2 release files

1.4

2 release files

1.3

2 release files

1.2

2 release files

1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page