How to Change the Default Icon on a Tkinter Window
In this tutorial, we are going to see different methods to change the default icon on a Tkinter window in Python. Using:
- root.iconbitmap()
- root.tk.call()
- root.iconphoto()
Method 1: Change the Default Icon Using root.iconbitmap()
iconbitmap(bitmap) sets the window icon to bitmap. The bitmap must be of type ico, but not of type png or jpg, otherwise the image will not be displayed as an icon.
import tkinter as tk root = tk.Tk() root.geometry("200x200") root.iconbitmap('C:\\Users\\Pc\\Desktop\\icon.ico') root.mainloop()
Output:

Method 2: Change the Default Icon Using root.tk.call()
import tkinter as tk root = tk.Tk() root.geometry("200x200") root.tk.call( 'wm', 'iconphoto', root._w, tk.PhotoImage(file='C:\\Users\\Pc\\Desktop\\icon.png') ) root.mainloop()
Output:

Method 3: Change the Default Icon Using root.iconphoto()
import tkinter as tk root = tk.Tk() root.geometry("200x200") root.iconphoto(False, tk.PhotoImage(file='C:\\Users\\Pc\\Desktop\\icon.png')) root.mainloop()
Output:
