0

I am working on winows 7 and python 3.8.2. I have an error. I wanted to upload an Image in a tkinter window. I tried importing a .gif file and I get an error as

"couldn't recognize data in image file". Though the file is in the correct path the error is happening. Can you please help me?

Here is the Code

from tkinter import *
window = Tk()
window.title("try")
canvas = Canvas(window, height = 500, width = 500)
canvas.pack()
my_image = PhotoImage(file = "C:\\Users\\jeeva\\Pictures\\bulbon.gif")
canvas.create_image(0, 0,  anchor = NW, image = my_image)
window.mainloop()

And here is the error:

Traceback (most recent call last):
  File "C:\Users\jeeva\Desktop\Tanmay_new\python\Codes\Not Finished\tett.py", line 6, in <module>
    my_image = PhotoImage(file = "C:\\Users\\jeeva\\Pictures\\bulbon.gif")
  File "C:\Users\jeeva\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 4061, in __init__
    Image.__init__(self, 'photo', name, cnf, master, **kw)
  File "C:\Users\jeeva\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 4006, in __init__
    self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't recognize data in image file "C:\Users\jeeva\Pictures\bulbon.gif"

Thank you, Regards, Tanmay

math scat
  • 310
  • 8
  • 17

0 Answers0