In this article we want to learn about Adding Images and Icons to Tkinter GUIs, Graphical User Interfaces (GUIs) have become an essential part of modern computing. they allow users to interact with software and applications in user friendly way. Tkinter is popular GUI library for Python programming language. It is simple to use, flexible and highly customizable. one of the important features of any GUI is the ability to add images and icons to make it more visually appealing and enhance the user experience. in this article we are going to discuss how to add images and icons to Tkinter GUIs.
Adding Images
Tkinter allows you to add images to your GUI using the PhotoImage class. PhotoImage class is used to display images in Tkinter window. this is is an example of how to add an image to Tkinter GUI:
1 2 3 4 5 6 7 8 9 10 11 12 |
from tkinter import * root = Tk() # Create a PhotoImage object image = PhotoImage(file="image1.png") # Add the image to a Label widget label = Label(root, image=image) label.pack() root.mainloop() |
In the above example first of all we have imported Tkinter module and created Tk object. after that we creates PhotoImage object and specify the path to the image file, and finally we add the image to Label widget and pack it into the Tk window using the pack() method.
It is important to note that the PhotoImage class only supports few file formats, such as GIF, PNG and PPM. If you need to display other image formats, you can use external libraries like Pillow or OpenCV to convert the image to supported format.
Run the complete code and this will be the result

Adding Icons
Icons are small images that represent an application or program. they are usually displayed in title bar of window or on the taskbar. Tkinter allows you to add icons to your GUI using iconbitmap() method. this is an example of how to add an icon to Tkinter GUI:
1 2 3 4 5 6 7 8 9 10 11 |
from tkinter import * root = Tk() # Set the window title root.title("GeeksCoders.com") # Set the window icon root.iconbitmap("geeks.ico") root.mainloop() |
In the above example first we have created Tk object and set the window title. after that we set window icon using the iconbitmap() method and specifying the path to the icon file. it is important to note that iconbitmap() method only supports a few file formats, such as ICO and BMP.
Run the complete code and this will be the result

In result we can say that Adding images and icons to Tkinter GUIs can greatly enhance the user experience and make your application more visually appealing. In this article we have learned how to add images using PhotoImage class and how to add icons using iconbitmap() method. with these techniques you can create more professional looking GUIs.
Learn More on TKinter
- How to Create Conutdown Timer with Python & TKinter
- Create GUI Applications with Python & TKinter
- Python TKinter Layout Management
- How to Create Label in TKinter
- How to Create Buttin in Python TKinter
- Build Music Player in Python TKinter
- Python GUI Programming with TKinter
- TKinter VS PyQt, Which one is Good
- Creating Custom Widgets in TKinter