2

Searching for the best way to clear the Tkinter icon, I found Removing the TK icon on a Tkinter window. But all the answers given there seemed unsatisfactory to me: I wished to do it in a platform-independent way, without additional files and without (compressed) inline data.

However, the solution I found – and that's why I didn't post this a an answer – has a small flaw that I would like to understand.

import tkinter as tk
from PIL import Image, ImageTk

root = tk.Tk()

photo = ImageTk.PhotoImage(Image.new('RGBA', (1,1), (0,0,0,1)))
root.iconphoto(False, photo)

root.mainloop()

The alpha value I'm using here is 1 instead of 0, so there is no full transparency even if probably no one will be able to see the difference. If I use 0 to get full transparency as documented, a small black square (larger than 1x1) is shown instead.

I wasn't able to find any information about what causes this strange (but maybe acceptable?) behavior. And so I would be happy if any of you could give me an explanation.

Wolf
  • 9,679
  • 7
  • 62
  • 108
  • you tried `"-transparent" , "your_color"`? so i know that works for your widgets, but with icons i don't know. so find the background of your icon out – bangKok May 28 '21 at 17:35

0 Answers0