I've been trying to use tkinter for creating GUI with Python, today I decided to use images in my GUI, but while using Canvas from tkinter I ran into this error:
Traceback (most recent call last):
File "C:\Users\37063\Desktop\pomodoro\main.py", line 25, in <module>
canvas.create_image((100, 112), image_canvas)
File "C:\Users\37063\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 2786, in create_image
return self._create('image', args, kw)
File "C:\Users\37063\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 2772, in _create
return self.tk.getint(self.tk.call(
_tkinter.TclError: unknown option "pyimage1" .
Here's my code:
from tkinter import *
window = Tk()
window.title("Gui test")
canvas = Canvas(width=200, height=224)
image_canvas = PhotoImage(file='ygo.gif')
canvas.pack()
canvas.create_image((100, 112), image_canvas)
window.mainloop()
As I googled the error I saw that sometime it is solved by changing your image format, I tried .png, .jpeg, .gif and none of them seem to work for me. Thank you for your advise in advance :)