Skip to main content
St Louis

Back to all posts

How to Add an Image In Tkinter?

Published on
5 min read
How to Add an Image In Tkinter? image

Best Books on Tkinter to Buy in October 2025

1 Python GUI Programming with Tkinter: Design and build functional and user-friendly GUI applications, 2nd Edition

Python GUI Programming with Tkinter: Design and build functional and user-friendly GUI applications, 2nd Edition

BUY & SAVE
$25.62 $49.99
Save 49%
Python GUI Programming with Tkinter: Design and build functional and user-friendly GUI applications, 2nd Edition
2 Modern Tkinter for Busy Python Developers: Quickly learn to create great looking user interfaces for Windows, Mac and Linux using Python's standard GUI toolkit

Modern Tkinter for Busy Python Developers: Quickly learn to create great looking user interfaces for Windows, Mac and Linux using Python's standard GUI toolkit

BUY & SAVE
$30.05 $39.99
Save 25%
Modern Tkinter for Busy Python Developers: Quickly learn to create great looking user interfaces for Windows, Mac and Linux using Python's standard GUI toolkit
3 Python and Tkinter Programming

Python and Tkinter Programming

  • QUALITY ASSURANCE: ENJOY GREAT VALUE WITH THOROUGHLY VETTED USED BOOKS.
  • ECO-FRIENDLY CHOICE: SUPPORT SUSTAINABILITY BY BUYING SECONDHAND BOOKS.
  • COST SAVINGS: SAVE MONEY WHILE EXPANDING YOUR READING COLLECTION TODAY!
BUY & SAVE
$43.96 $49.95
Save 12%
Python and Tkinter Programming
4 Building Modern GUIs with tkinter and Python: Building user-friendly GUI applications with ease (English Edition)

Building Modern GUIs with tkinter and Python: Building user-friendly GUI applications with ease (English Edition)

BUY & SAVE
$34.95
Building Modern GUIs with tkinter and Python: Building user-friendly GUI applications with ease (English Edition)
5 Python Tkinter 35 Mini Projects: Practical guide for begineer (Python Made Practical: 125 GUI Creative Projects and 500 Assignments)

Python Tkinter 35 Mini Projects: Practical guide for begineer (Python Made Practical: 125 GUI Creative Projects and 500 Assignments)

BUY & SAVE
$12.99
Python Tkinter 35 Mini Projects: Practical guide for begineer (Python Made Practical: 125 GUI Creative Projects and 500 Assignments)
6 A Simple Guide to Python GUI: Using the Standard Tkinter Library

A Simple Guide to Python GUI: Using the Standard Tkinter Library

BUY & SAVE
$14.00
A Simple Guide to Python GUI: Using the Standard Tkinter Library
7 Tkinter GUI Application Development Blueprints: Master GUI programming in Tkinter as you design, implement, and deliver 10 real-world applications

Tkinter GUI Application Development Blueprints: Master GUI programming in Tkinter as you design, implement, and deliver 10 real-world applications

BUY & SAVE
$21.46 $48.99
Save 56%
Tkinter GUI Application Development Blueprints: Master GUI programming in Tkinter as you design, implement, and deliver 10 real-world applications
8 Python GUI Programming with Tkinter: Develop responsive and powerful GUI applications with Tkinter

Python GUI Programming with Tkinter: Develop responsive and powerful GUI applications with Tkinter

BUY & SAVE
$28.76 $48.99
Save 41%
Python GUI Programming with Tkinter: Develop responsive and powerful GUI applications with Tkinter
9 PYTHON TKINTER GUI PROJECTS: PRACTICAL EXERCISES FOR BEGINNERS (Python Made Practical: 125 GUI Creative Projects and 500 Assignments)

PYTHON TKINTER GUI PROJECTS: PRACTICAL EXERCISES FOR BEGINNERS (Python Made Practical: 125 GUI Creative Projects and 500 Assignments)

BUY & SAVE
$12.99
PYTHON TKINTER GUI PROJECTS: PRACTICAL EXERCISES FOR BEGINNERS (Python Made Practical: 125 GUI Creative Projects and 500 Assignments)
10 Tkinter GUI Application Development Cookbook: A practical solution to your GUI development problems with Python and Tkinter

Tkinter GUI Application Development Cookbook: A practical solution to your GUI development problems with Python and Tkinter

BUY & SAVE
$38.68 $43.99
Save 12%
Tkinter GUI Application Development Cookbook: A practical solution to your GUI development problems with Python and Tkinter
+
ONE MORE?

To add an image in a tkinter window, you can use the PhotoImage class from the tkinter module. First, import the tkinter module, then create a PhotoImage object by specifying the path to the image file. Next, create a Label widget and set its image attribute to the PhotoImage object. Finally, use the pack() or grid() method to display the image in the tkinter window.

How to place an image at a specific position in tkinter?

To place an image at a specific position in a tkinter window, you can use the create_image method of the Canvas widget. Here's an example of how you can do this:

import tkinter as tk

Create the main tkinter window

root = tk.Tk()

Create a Canvas widget

canvas = tk.Canvas(root, width=400, height=400) canvas.pack()

Load the image

image = tk.PhotoImage(file="image.png")

Place the image at a specific position on the canvas

image_id = canvas.create_image(100, 100, image=image)

Run the tkinter main loop

root.mainloop()

In this example, we first create a Canvas widget with a specific width and height. We then load an image using the PhotoImage class and use the create_image method of the canvas to place the image at a specific position (100, 100 in this case) on the canvas.

You can adjust the position and size of the image by changing the coordinates passed to the create_image method.

What is the default image format supported by tkinter?

The default image format supported by tkinter is the GIF image format.

There is no specific recommended size for images in tkinter GUI applications as it depends on the design and layout of your application. However, it is generally recommended to use images with a resolution of 72-96 pixels per inch (ppi) for better display quality on standard screens. You can resize the images in your code using the PIL module if needed to fit them into your GUI layout.

How to rotate an image in tkinter?

To rotate an image in tkinter, you can use the PIL (Python Imaging Library) module to manipulate the image. Here is an example code snippet that rotates an image by a specified angle:

from tkinter import * from PIL import Image, ImageTk

Load the image

image = Image.open("image.jpg")

Rotate the image by 90 degrees

rotated_image = image.rotate(90)

Convert the rotated image to a PhotoImage object

tk_image = ImageTk.PhotoImage(rotated_image)

Create a tkinter window

root = Tk()

Display the rotated image

label = Label(root, image=tk_image) label.pack()

root.mainloop()

In this code snippet, we first load the image using the Image.open() method from the PIL module. We then use the rotate() method to rotate the image by the specified angle (in this case, 90 degrees). Finally, we convert the rotated image to a PhotoImage object using ImageTk.PhotoImage() and display it in a tkinter window with a Label widget.

Please make sure to replace "image.jpg" with the actual path to the image file that you want to rotate.

How to create a thumbnail of an image in tkinter?

To create a thumbnail of an image in tkinter, you can use the PIL (Python Imaging Library) module. First, you need to install the Pillow library which is a fork of PIL and provides more functionalities. You can install it using the following command:

pip install Pillow

Then, you can use the following code to create a thumbnail of an image in tkinter:

from tkinter import * from PIL import Image, ImageTk

Load the image

image = Image.open("image.jpg")

Create a thumbnail of the image

image.thumbnail((100, 100))

Convert the image to Tkinter format

tk_image = ImageTk.PhotoImage(image)

Create a tkinter window and display the thumbnail

root = Tk() label = Label(root, image=tk_image) label.pack()

root.mainloop()

In this code, replace "image.jpg" with the path to your image file. The thumbnail() method resizes the image to the specified size (in this case, 100x100 pixels). The ImageTk.PhotoImage() function is used to convert the image to a format that tkinter can use to display images.

Run this code and you will see a tkinter window displaying a thumbnail of the image.

How to add a border to an image in tkinter?

To add a border to an image in tkinter, you can use the PIL (Python Imaging Library) to open an image, create a new image with a border, and paste the original image onto the new image with the border. Here is an example code snippet to add a border to an image in tkinter:

from tkinter import * from PIL import Image, ImageTk

Open an image file

image = Image.open("example.jpg")

Create a new image with a border

border_width = 10 new_image = Image.new("RGB", (image.width + 2*border_width, image.height + 2*border_width), "white")

Paste the original image onto the new image with the border

new_image.paste(image, (border_width, border_width))

Convert the new image to a tkinter PhotoImage

tk_image = ImageTk.PhotoImage(new_image)

Create a tkinter window and display the image with a border

root = Tk() label = Label(root, image=tk_image) label.pack() root.mainloop()

Make sure to replace "example.jpg" with the path to your image file. This code will open the image, create a new image with a border, paste the original image onto the new image with the border, and display the image with a border in a tkinter window.