0
    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 1

2

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)
Sign up to request clarification or add additional context in comments.

3 Comments

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.
Try import PIL.Image instead of from PIL import Image
Error remains the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.