Win32mica: a simple module to add the Mica effect on legacy python windows.

Overview

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.

View this project also on PyPi

Installation:

python -m pip install win32mica

Requirements:

  • Windows 11
  • A frameless window (It might work with a normal window, bit it is not guaranteed.)
  • The HWND (identifier) of that window. More info: what is a hwnd?
  • The window must have semi-transparent widgets/controls in order to recreate the transparency effect.
  • Know if Windows has dark or light mode enabled. This can be checked with the darkdetect module

Usage:

hwnd = qtwindow.winId() # 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

import darkdetect # Auto mode detect
mode = darkdetect.isDark()

win32mica.ApplyMica(hwnd, mode)

Result:

Demo
This is a PySide2 window with custom transparent widgets. The screenshot has been taken on dark mode.

Comments
  • Error when applying mica

    Error when applying mica

    Hi! Reallay awsome project! I get this error when running on tkinter window: Code: ApplyMica(HWND=windll.user32.GetParent(app.winfo_id()), ColorMode=True) Error:

      File "D:\Coding\TimerX\main.py", line 783, in makeWindowsBlur
        ApplyMica(HWND=windll.user32.GetParent(app.winfo_id()), ColorMode=True)
      File "C:\Users\suchi\AppData\Local\Programs\Python\Python310\lib\site-packages\win32mica\__init__.py", line 54, in ApplyMica        
        SetWindowCompositionAttribute(HWND, Wca)
    ctypes.ArgumentError: argument 2: <class 'TypeError'>: expected WINDOWCOMPOSITIONATTRIBDATA instance instead of WindowCompositionAttribute
    
    opened by sumeshir26 11
  • Compiling with cx_Freeze

    Compiling with cx_Freeze

    Hello! I am using win32mica in a program, and when running the program from the .py file, everything works flawlessly. But when i compile the program to an execuetable using cx_Freeze, win32mica throws the following error:

    Win32Mica Error: win32 version 9200 is not supported

    What does that mean and how do i fix it?

    opened by not-nef 8
  • Change the ColorMode=MICAMODE.LIGHT but it's still dark!

    Change the ColorMode=MICAMODE.LIGHT but it's still dark!

    Not sure if I did something wrong My code:

    def Light():
        app.tk.call("ttk::style", "theme", "use") == "sun-valley-dark"
        app.tk.call("set_theme", "light")
        bg_color = ttk.Style().lookup(".", "background")
        app.wm_attributes("-transparent", bg_color)
        HWND=windll.user32.GetParent(app.winfo_id())
        ApplyMica(HWND, ColorMode=MICAMODE.LIGHT)
        app.update()
    
    def Dark():
        app.tk.call("ttk::style", "theme", "use") == "sun-valley-dark"
        app.tk.call("set_theme", "dark")
        bg_color = ttk.Style().lookup(".", "background")
        app.wm_attributes("-transparent", bg_color)
        HWND=windll.user32.GetParent(app.winfo_id())
        ApplyMica(HWND, ColorMode=MICAMODE.DARK)
        app.update()
    

    Result:

    https://user-images.githubusercontent.com/86362423/156988497-26c5d22c-f3fa-4148-ae41-890c3842c24a.mp4

    opened by HuyHung1408 7
  • ValueError: invalid literal for int() with base 10: '0xa20856'

    ValueError: invalid literal for int() with base 10: '0xa20856'

    My code is:

    import tkinter
    from tkinter import ttk
    
    import sv_ttk
    root = tkinter.Tk()
    root.geometry('400x100+200+200') # set new geometry
    from win32mica import MICAMODE, ApplyMica
    import darkdetect # You can pass the darkdetect return value directly, since the ColorMode accepts bool values (True -> dark, False -> light)
    mode = darkdetect.isDark()
    
    hwnd = root.frame() # On a tkinter window
    ApplyMica(hwnd, mode)
    
    button = ttk.Button(root, text="Click me!")
    button.pack()
    
    
    # This is where the magic happens
    if darkdetect.isDark():
      sv_ttk.set_theme("dark")
    else:
      sv_ttk.set_theme("light")
    
    root.mainloop()
    

    Applying Win32Mica messed it up.

    Is it a bug in Win32Mica, or a bug in my code?

    EDIT: Here is the backlog appearing when running the script:

    Traceback (most recent call last):
      File "C:\Users\tyler\fluent-tkinter.py", line 12, in <module>
        ApplyMica(hwnd, mode)
      File "C:\Users\tyler\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\win32mica\__init__.py", line 18, in ApplyMica
        HWND = int(HWND)
    ValueError: invalid literal for int() with base 10: '0xa20856'
    
    opened by TylerMS887 6
  • Issue in focus

    Issue in focus

    By clicking on the part where mica is used, the program minimizes. If the topmost attribute is applied, the window loses focus, and the mica effect is no longer visible.

    opened by jaivardhan-bhola 6
  • Everything works but the I cannot close the thing after restoring a minimised window

    Everything works but the I cannot close the thing after restoring a minimised window

    I made a tkinter application which uses this beautiful mica style, and everything worked. The mica applies fine, there are no errors related to HWND, but there is this one issue. When I restore a minimised window, there are no hitboxes for any buttons on the titlebar. This isssue is related to #7 where OP was not able to focus his window. The same thing happens here, but the only clickable buttons are the ones I made by myself in python, the close, maximise and minimise buttons don't really work

    From #7 , I found out that this issue was a tkinter one, is it the case here too?

    yes

    From this gif, I was trying to click the minimise button again, but the click is registered on the desktop instead of the app itself

    opened by SlavBoi420 5
  • Can't change mica theme without reopening app.

    Can't change mica theme without reopening app.

    while using this i noticed that when you want to change the mica effect whilst the app was open, you could only change from light to dark, but not back.

    https://user-images.githubusercontent.com/97522577/188254033-d63b16d9-9641-4a67-b61c-c3d8564d6eef.mp4

    opened by Cowski0 3
Releases(1.7.1)
LyricsGenerator - A simple GUI made using Python(Tkinter) for generating song lyrics

Lyrics Generator Reference :- https://www.geeksforgeeks.org/create-a-gui-to-extr

Somya Ranjan Sahu 3 Mar 25, 2022
Dress up your code with a beautiful graphical user interface !

Dresscode Dress up your code with a beautiful graphical user interface ! This project is part of the Pyrustic Ecosystem. Look powered by the cyberpunk

20 Aug 24, 2022
Randomly picks between your favourite meals for you when you're feeling indecisive.

Food Recommendations Desktop application created with python and tkinter. The goal for this application is to provide a way for users to enter and sav

Jesse Kartabani 1 Dec 07, 2021
This is a short GUI project to evaluate Pbk solution.

Polubarinova-Kochina-solutions (Standalone GUI executables for Windows and Mac) Oden Institute for Computational Engineering and Sciences / Jackson Sc

Mohammad Afzal Shadab 1 Dec 24, 2022
GUIOfTemperatureConverterUsingPython - GUI Of Temperature Converter Using Python

Fahrenheit To Celcius GUI Of Temperature Converter Below Video is the Output Of

SUJITHA RASAMSETTY 0 Mar 06, 2022
GUI to enable user selection of measurement and station in kHTConnector module.

kHTGui GUI to enable user selection of measurement and station in kHTConnector module. Helper tool for PowerBI users If you're planning to import data

kk 1 Jan 26, 2022
A Python Tkinter based Inventory managment System

Inventory Management System Using Python Tkinter Introduction Inventory managemrnt system is an open source platform for manage business. It has a com

Amit Kumar Datta 2 Oct 14, 2021
Key Cast - Cast your key presses and mouse clicks on the screen, while casting your favorite application on the screen. Better than the rest.

Key Cast Screen cast your keyboard and mouse clicks in style Project Homepage » View Demo · Report Bug · Request Feature Table of Contents Introductio

Mehul Singh Teya 13 Dec 23, 2022
GUI for Volatility forensics tool written in PyQT5

Volatility GUI This is a GUI for Volatility forensics tool written in PyQT5 Prerequisites: 1- Installed version of Volatility. 2- Install PyQT5. sudo

Hamza Megahed 52 Jun 18, 2022
Write interactive web app in script way.

PyWebIO Write interactive web app in script way. [Document] | [Demos] | [Why PyWebIO?] English | 中文 PyWebIO provides a series of imperative functions

PyWebIO 3.6k Dec 31, 2022
A lightweight file-copying interface.

autosort A lightweight file-copying interface. Preview What is autosort? Autosort is a lightweight file-copying interface. It allows you to copy sever

32 Jan 02, 2023
Nonton anime subtitle Indonesia tanpa iklan. Dengan GUI berbasis PyQt5 dan spaghetti code yang sangat tidak terstruktur

Nonton anime subtitle Indonesia tanpa iklan. Dengan GUI berbasis PyQt5 dan spaghetti code yang sangat tidak terstruktur

Ayra Hikari 21 Dec 18, 2022
EZ Presence - A GUI-Python app which makes it easy to set a custom Discord Rich Presence. (BETA)

EZ Presence EZ Presence is a GUI-Python app which makes it easy to set any custom Discord Rich Presence. Using the App How to Run Since the app is in

notsniped 2 Mar 01, 2022
CBMPy Metadraft: a flexible and extensible genome-scale model reconstruction tool

CBMPy Metadraft: a flexible and extensible, GUI-based genome-scale model reconstruction tool that supports multiple Systems Biology standards.

Systems Biology Lab, Vrije Universiteit Amsterdam 1 Mar 14, 2022
Advanced GUI Discord Account Nuker that is easy to use, with many features.

AccountNukeV3 Showcase Youtube: Features: Remove all friends Block all friends Leave all servers Mass create servers Close all dms Mass dm Fuck Settin

Lodi#0001 24 May 22, 2022
This simple python program can be used to make FontChooser dialog in Tkinter Applications.

tkFontBox This simple python program can be used to make FontChooser dialog in Tkinter Applications. how to use? Copy the tkFontBox.py file into your

Pawan Kumar Prachi 1 Feb 08, 2022
GUI Python Auto text bot.

Bagel Text Bot Auto text bot. Written in Python. Contributing Pull requests are welcome. For major changes, please open an issue first to discuss what

Toby 3 May 14, 2022
My Git GUI version made in Python and Tkinter.

Description My Git GUI version made in Python and Tkinter. How to use Basically, create a folder in your computer, open the software, select the path

Matheus Golzio 4 Oct 10, 2021
Learn to build a Python Desktop GUI app using pywebview, Python, JavaScript, HTML, & CSS.

Python Desktop App Learn how to make a desktop GUI application using Python, JavaScript, HTML, & CSS all thanks to pywebview. pywebview is essentially

Coding For Entrepreneurs 55 Jan 05, 2023
GUI app to read settings and stats from Cloudflare WARP CLI for Linux, and change some settings

warp-cli-gui GUI app to read settings and stats from Cloudflare WARP CLI for Linux, and change some settings. Description Python program that will int

Danie 6 Nov 01, 2022