Tkinter Transparent Background macOS

Viewed 12

I've been messing around with different code snippets and combinations for a while now, trying to make it so my .gif file would have a transparent background. I've been successful in making the actual background transparent, but I find that my .gif goes transparent with it:

import tkinter as tk

root = tk.Tk()
root.overrideredirect(1)
root.wm_attributes("-topmost", True)
root.wm_attributes("-transparent", True)
root.config(bg='systemTransparent')

root.geometry("+300+300")

root.image = tk.PhotoImage(file="sample.gif")
label = tk.Label(root, image=root.image)
label.config(bg='systemTransparent')
label.pack()

root.mainloop()

I have found that whenever I use both root.config(bg='systemTransparent') and label.config(bg='systemTransparent'), the entire window and gif go transparent, but when I use just one or neither, I am left with a light-gray background.

0 Answers
Related