I have already made a post on how to open a JPG file but I now plan to use GIF image files. Can someone show me a sample code example on how to open GIF image files whenever you click buttons on TKinter GUI in Python? Thanks.

Something like this usaully works:

# Python2 (for Python3 use tkinter)
import Tkinter as tk

def show_image():
    lbl['image'] = image_tk

root = tk.Tk()

# pick a .gif image file you have in the working folder
# or give the full path
fname = "House.gif"
image_tk = tk.PhotoImage(file=fname)

btn = tk.Button(root, text="load image", command=show_image)
btn.pack(pady=10)

lbl = tk.Label(root)
lbl.pack()

root.mainloop()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.