Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when applying mica #2

Closed
sumeshir26 opened this issue Feb 23, 2022 · 11 comments
Closed

Error when applying mica #2

sumeshir26 opened this issue Feb 23, 2022 · 11 comments

Comments

@sumeshir26
Copy link

sumeshir26 commented Feb 23, 2022

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
@marticliment
Copy link
Owner

Can't you get the hwnd of the window using the .frame() function?

Becayer you need to apply this on each window, and not in the app itself

@marticliment
Copy link
Owner

*Because

Aditionally, Are you using any kind of library like PythonBlurBehind?

@sumeshir26
Copy link
Author

sumeshir26 commented Feb 23, 2022

I used to use PythonBlurBehind, but now removed it. The app's background is transparent for PythonBlurBehind. Should I make it solid again?

@sumeshir26
Copy link
Author

When using .frame, same error

@marticliment
Copy link
Owner

The issue is because of ctypes interferences. My soolution was to use a moded version of it. You only have to remove the declarations of the rgument datatypes.

SetWindowCompositionAttribute.argtypes = (HWND, WINDOWCOMPOSITIONATTRIBDATA)
SetWindowCompositionAttribute.restype = ctypes.c_int

I also faced the same issue, and finished by modding the module

@sumeshir26
Copy link
Author

So I need to mod ctypes? I cant find matching lines in this code

@marticliment
Copy link
Owner

No need to mod ctypes but the pythonBlurBehind module

Although it may not be used, when the moduleis imported it interfiers with win32mica because of those two lines in the PythonBlurBehind Module. Commend them (the module will still work) and everyuthing should go fine

@marticliment
Copy link
Owner

https://github.com/martinet101/ElevenClock/blob/main/elevenclock/external/blurwindow.py

This is an exapmle taken from ElevenClock

@sumeshir26
Copy link
Author

That fixed it! But is there any way to remove the black box on the title or disable ExpandFrameIntoClientArea until the titlebar text is fixed on Beta Channel?

@marticliment
Copy link
Owner

I don't think so. My approach was to literally set an empty string as titlebar and an empty icon on window icon. With this set it does look good

@sumeshir26
Copy link
Author

Thank you for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants