My full code
from tkinter import *
i=0
for i in range(10) :
window = Tk()
window.title('add image')
window = Canvas(window,width= 600, height= 600)
window.pack()
image=PhotoImage(file=r"C:\\Users\\Konstantinos\\New folder\\hello.png")
window.create_image(0,0, anchor = NW, image=image)
window.mainloop()
The error when i run the program
File "C:\Programms\Lib\tkinter\__init__.py", line 2832, in _create
return self.tk.getint(self.tk.call(
^^^^^^^^^^^^^
_tkinter.TclError: image "pyimage2" doesn't exist
The error when i debug the program
Exception has occurred: TclError
image "pyimage2" doesn't exist
File "C:\Users\Konstantinos\New folder\demo.py", line 9, in <module>
window.create_image(0,0, anchor = NW, image=image)
So basically, the program opens an image multiple times. When th program is not in a loop it works but when i put it in a loop it gives me the error. Because i recently started programming i dont really know how to solve the problem and I have looked in other threads with the similar problem but none apply to me. I will appreciate any answer