Removing the TK icon on a Tkinter window

PythonTkinterServer Side ProgrammingProgramming

Tkinter initially displays a window that contains all the widgets and components. When we look on the Tkinter Menubar, it displays some "leaf" default icon for every Tkinter application. In order to change the default icon of the Tkinter window, we can use iconbitmap("icon location") method. It takes the location of the icon file and displays the window with a particular icon.

Example

In this python script, we have created an icon and used it for the output window.

#Import tkinter library
from tkinter import *
#Create an instance of tkinter frame or window
win= Tk()
#Set the geometry of tkinter frame
win.geometry("750x250")
#Change the icon of window taskbar
win.iconbitmap("favicon.ico")
#Create a Label
Label(win, text="Transparent Icon Window", font=('Lucida 15')).pack()
win.mainloop()

Output

Running the above code will display a window that has a customized Icon on the MenuBar.

raja
Published on 22-Apr-2021 07:44:33
Advertisements