Is there a way to get a transparent background in a Tkinter window on Linux?
The only way I see currently is:
import tkinter as tk
root = tk.Tk()
root.overrideredirect(True)
root.wait_visibility(True)
root.wm_attributes("-alpha", 0.0)
canvas = tk.Canvas(root, width=300, height=300)
canvas.pack()
canvas.create_rectangle(50, 25, 150, 75, fill="red")
root.mainloop()
However, this is not what I want. I want to get the background to be transparent so my overlay can be something else.
I found a couple posts here, but they only cover bg transparency on Windows and Mac OS. The Linux related one is only alpha?
linux mint tkinter transparent window
transparent background in a tkinter window
It worked for me on Ubuntu 20.04, Linux Mint 20.1, Cinnamon
Python 3.6
import tkinter as tk
root = tk.Tk()
#root.overrideredirect(True)
root.wait_visibility(root)
root.wm_attributes("-alpha", 0.5)
root.mainloop()
Use `root.overrideredirect(True)´ if you want that the window manager does not handle the window at all, except when you explicitly tell it to map or unmap it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With