Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux Mint Tkinter transparent window

I am trying to have a transparent background using Tkinter:

from tkinter import *
root = Tk()
root.attributes('-alpha', 0.1)
# root.wm_attributes('-alpha', 0.1) 
# root.wm_attributes("-transparentcolor", "white")
# root.attributes("-fullscreen",True)
root.mainloop()

This code works fine in Windows, but not using Linux Mint Maya. Commented out are other options I have tried. Any suggestions what might be wrong?

like image 231
user1908460 Avatar asked Jan 01 '26 09:01

user1908460


1 Answers

When you set the attribute, the window is not yet in a start where that works. To wait for that, add root.wait_visibility(root):

from tkinter import *
root = Tk()
root.wait_visibility(root)
root.attributes('-alpha', 0.6)
root.mainloop()

(Confusingly, it can also work as a side effect of something else, like setting the window state, even to the same state it has.)

like image 53
Volker Siegel Avatar answered Jan 02 '26 22:01

Volker Siegel