'self.tk.call(('image', 'create', imgtype, name,) + options) _tkinter.TclError: couldn't recognize data in image file "image1.png" - Unable to load png
I'm trying to make an app using Python and Tkinter but I'm not able to load an image, or png to be specific. Instead, I'm getting this long error:
File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 4038, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't recognize data in image file "image1.png".
Can someone help me fix this? Here are the lines of code that might be causing the error:
cycle1IMG = tk.PhotoImage(file="image1.png")
def openNewWindow1():
newWindow = Toplevel(master)
newWindow.title("🚲Cycle 1")
newWindow.geometry("750x500")
Label(newWindow, text="Cycle 1", image= cycle1IMG).pack()
cycle1 =tk.Button(
root,
text="🚲Cycle 1",
command=openNewWindow1
)
cycle1.place(x=500,y=300)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
