Removing the TK icon on a Tkinter window Removing the TK icon on a Tkinter window tkinter tkinter

Removing the TK icon on a Tkinter window


On Windows

Step One:

Create a transparent icon using either an icon editor, or a site like rw-designer. Save it as transparent.ico.

Step Two:

from tkinter import *tk = Tk()tk.iconbitmap(default='transparent.ico')lab = Label(tk, text='Window with transparent icon.')lab.pack()tk.mainloop()

On Unix

Something similar, but using an xbm icon.


Similar to the accepted answer (with the con of being uglier):

import tkinterimport tempfileICON = (b'\x00\x00\x01\x00\x01\x00\x10\x10\x00\x00\x01\x00\x08\x00h\x05\x00\x00'        b'\x16\x00\x00\x00(\x00\x00\x00\x10\x00\x00\x00 \x00\x00\x00\x01\x00'        b'\x08\x00\x00\x00\x00\x00@\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'        b'\x00\x01\x00\x00\x00\x01') + b'\x00'*1282 + b'\xff'*64_, ICON_PATH = tempfile.mkstemp()with open(ICON_PATH, 'wb') as icon_file:    icon_file.write(ICON)tk = tkinter.Tk()tk.iconbitmap(default=ICON_PATH)label = tkinter.Label(tk, text="Window with transparent icon.")label.pack()tk.mainloop()

It just creates the file on the fly instead, so you don't have to carry an extra file around. Using the same method, you could also do an '.xbm' icon for Unix.

Edit: The ICON can be shortened even further thanks to @Magnus Hoff:

import base64, zlibICON = zlib.decompress(base64.b64decode('eJxjYGAEQgEBBiDJwZDBy'    'sAgxsDAoAHEQCEGBQaIOAg4sDIgACMUj4JRMApGwQgF/ykEAFXxQRc='))


Based on previous responses i used this solution:

from PIL import ImageTkimport zlib,base64import Tkintericon=zlib.decompress(base64.b64decode('eJxjYGAEQgEBBiDJwZDBy''sAgxsDAoAHEQCEGBQaIOAg4sDIgACMUj4JRMApGwQgF/ykEAFXxQRc='))root=Tkinter.Tk()image=ImageTk.PhotoImage(data=icon)root.tk.call('wm', 'iconphoto', root._w, image)root.mainloop()