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)
GUI Pancakeswap 2 and Uniswap 3 SNIPER BOT 🥇 🏆 🥇

GUI Pancakeswap V2 and Uniswap V3 trading client (and bot) MOST ADVANCE TRADING BOT SUPPORT WINDOWS LINUX MAC (BUY TOKEN ON LAUNCH)

HYDRA 16 Dec 21, 2021
Declarative User Interfaces for Python

Welcome to Enaml Enaml is a programming language and framework for creating professional-quality user interfaces with minimal effort. What you get A d

1.4k Jan 07, 2023
Py address book gui - An address book with graphical user interface developed with Python Tkinter

py_address_book_gui An address book with graphical user interface developed with

Milton 4 Feb 01, 2022
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
Aplicação GUI feita em Python para estudos de cadastro (forms).

Cadastro de DEVs GUI 💻 A ideia original veio do repositório do https://github.com/PedroTomazeti nomeado 'Projetos-Independentes-HTML-CSS' Nele há um

Yago Goltara 3 Aug 15, 2021
Criando interfaces gráficas com Python e Qt 6 (PyQt6)

Criando interfaces gráficas com Python e Qt 6 (PyQt6) Qt O Qt é um framework para criação de interfaces gráficas multiplataforma, atualmente ele é des

Renato Cruz 1 Jun 07, 2022
Advanced Zola Cabs integrated with tkinter Graphical User Interface (GUI) made for ZOHO Corp .

ZolaCabs Advanced Zola Cabs integrated with tkinter Graphical User Interface (GUI) made for ZOHO Corp. Logs username : zoho password : zoho [ Deve

Mastermind 9 Nov 18, 2021
LCD GUI for P4wnP1 ALOA

GUI for P4wnP1 Colorful UI interface for P4wnP1 ALOA Don't pwn just as a USB client. Use also the USB host capabilities! UPS Lite support Scalability

John 7 Dec 13, 2022
Chatterpatter - A simple GUI complex backend Chat Application made using python

Chatterpatter - A simple GUI complex backend Chat Application made using python

Gurneet Singh 2 Jan 08, 2022
Software com funçoes de A a Z feito no Python

Introdução Iniciante em programação Python, decidi criar um programa com diversas ferramentas de A a Z. Funções Ferramenta de Gerenciamento e Manutenç

João Pedro 1 Jan 26, 2022
guietta - a tool for making simple Python GUIs

guietta - a tool for making simple Python GUIs

Alfio Puglisi 1.9k Jan 08, 2023
HDLG is a modern cross-platform GUI for hdl-dump with Batch installation capabilities.

HDLG is a modern cross-platform GUI for hdl-dump with Batch installation capabilities. Looking for Artwork This project is looking for an Icon an

8 Dec 03, 2022
A simple fusee-launcher frontend for macOS

A simple fusee-launcher frontend for macOS (Universal). Supports macOS = 10.9. It has libusb statically linked, so you don't need to install anything

rob 25 Dec 19, 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
A system tray application written in python that will assist you with your keyboard endeavors.

A system tray application written in python that will assist you with your keyboard endeavors. It has features such as abbreviation, email autofill, media control, writing from clipboard ,typing curr

Mach50 1 Dec 15, 2021
Create highly interactive web pages purely in Python

A package for building highly interactive user interfaces in pure Python inspired by ReactJS.

701 Jan 03, 2023
A really minimalistic operating system made using python's GUI module Tkinter.

BoxOS V1.0.0 About A really minimalistic operating system made using python's GUI module Tkinter. What seperates it from the other operating systems m

Fahim 2 Dec 08, 2022
Bill Cipher is a Python3 Tkinter Application that creates Python remote backdoors, while giving you the option to convert it to an exe.

Bill Cipher is a Python3 Tkinter Application that creates Python remote backdoors, while giving you the option to convert it to an exe. The program also configures a .py server file that works with t

Damian Mostert 2 Apr 12, 2022
Python Screen Recorder using Python

PY-Screen-Recorder Python Screen Recorder using Python Requirement: pip install cv2 pip install pyautogui pip install numpy How to reach me? You can r

SonLyte 8 Nov 08, 2021
Use CSS styling in Tkinter apps

cssTk To-Do Support Upto CSS 4.15 Set Up Docs Features * Corner Radius Gradient BG Blur Animations Usage Scenarios Allows easy import of GTK 3 and GTK

RUG 5 Oct 18, 2022