from tkinter import *
from PIL import ImageTk, Image
top = Tk()
file ='flame2.jpg'
filename = PhotoImage(file)
panel=PanedWindow()
panel = Label(top, image = filename)
panel.pack(side = "bottom", fill = "both", expand= "yes")
top.mainloop()
1 Answer
You should use PIL to read such complicated image formats and pass them as understandable objects to tkinter:
from PIL import Image, ImageTk
...
my_image = Image.open("flame2.jpg")
filename= ImageTk.PhotoImage(my_image)
...
panel = Label(top, image=filename)
3 Comments
Vaishnavi Vinay
my_image = Image.open("flame2.jpg") AttributeError: type object 'Image' has no attribute 'open' After compiling the code you sent, this is the error occured.
Billal BEGUERADJ
Try
import PIL.Image instead of from PIL import ImageVaishnavi Vinay
Error remains the same.