root.attributes("-transparentcolor", "white")
won't work with a .pyw
file extension
Up until yesterday all my tkinter GUIs have been working like they should but two days ago all of them stopped working like I want them to. The line root.attributes("-transparentcolor", "white")
has always made the white color transparent, like it should, but now it doesn't work like it used to. It does work properly if I launch the program with a .py
file extension but not with a .pyw
. Obviously I don't want a console window to open along with all of my programs so this is not something I could just accept. Like I said, this has worked fine up until yesterday.
For the past day I've been doing all kinds of things to try to fix this, I even uninstalled python completely and reinstalled the latest version, but nothing has changed my problem.
I'm on Windows 10 and python 3.9.1
right now (after the reinstall, cant remember what version I had before)
I didn't do a single thing that could've made this happen, I didn't update or change anything before my problem showed up, I simply started my computer in the morning like always.
Does anyone have any clue on what I could try? Could anyone try to do the same thing and see if it works for you?
Code below creates a tkinter window with a transparent background if saved as a .py file, but creates a tkinter window with white background if saved like a .pyw file.
from tkinter import *
root = Tk()
root.config(bg= 'white')
root.attributes('-transparentcolor', 'white')
root.mainloop()
Update:
Hmm... I've discovered something interesting!
If i start my program through cmd prompt with pythonw my problem still appears, but if i do the same thing with a cmd prompt running as administrator it all works like before, I get a transparent background!
Update 2:
I've set pythonw.exe to always run as administrator, and this solves my problem. But if I do that I always get a uac prompt wich I never got before, so I haven't fixed my problem, I've just found a tedious workaround.
question from:
https://stackoverflow.com/questions/65952507/tkinter-transparentcolor-working-with-py-but-not-with-pyw 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…