In this video we’ll learn how to add Images to our apps with Tkinter and Python.

Generally, to add an image to your TKinter app you’ll create a label, and then add the image to the label.

We’ll use the PIL (Python Imaging Library) to add the image to our app and I’ll also show you how to resize the image.

Python Code: images.py
(Github Code)

from tkinter import *
from PIL import ImageTk, Image

root = Tk()
root.title("Images - Intro To Tkinter")
root.iconbitmap('images/tkinter.ico')
root.geometry('600x400')

# Create our image
aspen = Image.open("images/aspen.png").resize((250,188))
aspen = ImageTk.PhotoImage(aspen)

# Create a label
my_label = Label(root, image=aspen, bd=2, relief="groove") #raised, ridge, sunken, groove, flat
my_label.pack(pady=20)

# Create a button Image
login = Image.open("images/login.png").resize((75,30))
login = ImageTk.PhotoImage(login)

# Create a button
my_button = Button(root, image=login, bd=0)
my_button.pack(pady=20)





root.mainloop()



John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of the first dot com boom. After that he developed the award-winning Submission-Spider search engine submission software that's been used by over 3 million individuals, businesses, and governments in over 42 countries. He's written several Amazon #1 best selling books on coding, and runs a popular Youtube coding channel.

View all posts

Add comment

Your email address will not be published. Required fields are marked *

John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of...