How do I add an image in Tkinter?
This gave me a syntax error:
root = tk.Tk() img = ImageTk.PhotoImage(Image.open(path)) panel = tk.Label(root, image = img) panel.pack(side = "bottom", fill = "both", expand = "yes") root.mainloop()
Images can be shown with tkinter. Images can be in a variety of formats including jpeg images.
Tkinter PhotoImage only supports the GIF, PGM, PPM, and PNG file formats.
Python 3.3.1 [MSC v.1600 32 bit (Intel)] on win32 14.May.2013
This worked for me, by following the code above
from tkinter import * from PIL import ImageTk, Image import os root = Tk() img = ImageTk.PhotoImage(Image.open("True1.gif")) panel = Label(root, image = img) panel.pack(side = "bottom", fill = "both", expand = "yes") root.mainloop()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With