DEV Community

Cover image for Make a Simple Image Gallery Using Tkinter and Python
MOOICT
MOOICT

Posted on

4

Make a Simple Image Gallery Using Tkinter and Python

Hi in this post I will be sharing with you how to make a image slide show using Tkinter and Python. I am slowly making progress into learning python and this project was kind of fun to work out. I am using the pillow (PIL) framework to show the images and resize them on the screen.

Here is the youtube tutorial video

Download Image Slide Show Images Here

Source code here

from tkinter import *
from PIL import ImageTk, Image
# set up the tkinter window
root = Tk()
root.title("MOO ICT Python/Tkinter Image Viewer")
root.geometry("610x430")
root.iconbitmap("images/icon.ico")
 
# set up the images
image1 = ImageTk.PhotoImage(Image.open("images/01.jpg").resize((600, 350)))
image2 = ImageTk.PhotoImage(Image.open("images/02.jpg").resize((600, 350)))
image3 = ImageTk.PhotoImage(Image.open("images/03.jpg").resize((600, 350)))
image4 = ImageTk.PhotoImage(Image.open("images/04.jpg").resize((600, 350)))
image5 = ImageTk.PhotoImage(Image.open("images/05.jpg").resize((600, 350)))
# add them to the list
image_list = [image1, image2, image3, image4, image5]
# counter integer
counter = 0
# change image function
def ChangeImage():
    global counter
    if counter < len(image_list) - 1:
        counter += 1
    else:
        counter = 0
    imageLabel.config(image=image_list[counter])
    infoLabel.config(text="Image " + str(counter + 1) + " of " + str(len(image_list)))
# set up the components
imageLabel = Label(root, image=image1)
infoLabel = Label(root, text="Image 1 of 5", font="Helvetica, 20")
button = Button(root, text="Change", width=20, height=2, bg="purple", fg="white", command=ChangeImage)
# display the components
imageLabel.pack()
infoLabel.pack()
button.pack(side="bottom", pady=3)
# run the main loop
root.mainloop()
Enter fullscreen mode Exit fullscreen mode

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up