Today I tried to put an image in a tkinter file and I tried PhotoImage. This is my code:
from tkinter import *
screen = Tk()
photo = PhotoImage(file = './Images/Test.png')
Button(screen, text = 'Click Me !', image = photo).pack()
screen.mainloop()
When I run it in VSCode:
File "/Users/pyman/Desktop/Coding/python/Periodic
table/tempCodeRunnerFile.py", line 5, in <module>
photo = PhotoImage(file = './Images/Test.png') File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py",
line 3377, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py",
line 3331, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't recognize data in image file "./Images/Test.png"
When I run it in IDLE, I don't get any error.
What I should do to run it in VS Code?