marticliment / win32mica

Win32mica: a simple module to add the Mica effect on legacy python windows.
https://pypi.org/project/win32mica
MIT License
95 stars 5 forks source link

Can't change mica theme without reopening app. #9

Closed Cowski0 closed 2 years ago

Cowski0 commented 2 years ago

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

marticliment commented 2 years ago

This is a weird bug that was discussed in #3. Note that the API that enables mica in W11 21h2 is not intended to be public, hence the bugs.

However, it should work with W11 22h2, coming soon.

If you want, share your code and i'll test it for you on W11 22h2, since I'm in the beta channel.

Cowski0 commented 2 years ago

here's my code, it still doesnt work, even when i went onto 22h2. but the titlebar thing fixed

import win32mica as mc
from PySide6 import QtWidgets, QtCore,QtGui
from PySide6.QtWidgets import *
from PySide6.QtGui import *
from PySide6.QtCore import *

class MainWindow(QMainWindow):

    def __init__(self):
        super().__init__()

        #remove icon
        self.resize(1600, 860)
        self.dark = False
        mc.ApplyMica(self.winId(), mc.MICAMODE.LIGHT)
        self.setAttribute(QtCore.Qt.WA_TranslucentBackground)

        btn = QPushButton("mica",self)
        btn.setGeometry(20,20, 200,200)
        btn.clicked.connect(self.mica)

    def mica(self):
        if self.dark == True:
            mc.ApplyMica(self.winId(), mc.MICAMODE.LIGHT)
            self.dark = False
        else:
            mc.ApplyMica(self.winId(), mc.MICAMODE.DARK)
            self.dark = True

import sys
app = QApplication(sys.argv)
mw = MainWindow()
mw.show()
sys.exit(app.exec())
marticliment commented 2 years ago

Mhmm, looks like i forgot to implement one undocumented API.

Could you please try Win32mica 1.6? It should work now.