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.
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()
Running the above code will display a window that has a customized Icon on the MenuBar.