I am using Tkinter with Python to create a GUI. I could not figure out how to display seaborn plots in tkinter (another problem), so I am trying to circumvent that by saving the plot as an image and then displaying it.
I have tried the following code to display an existing image:
from tkinter import *
from PIL import ImageTk, Image
window = Tk()
load = Image.open('plot.png')
render = ImageTk.PhotoImage(load)
img = Label(window, image=render)
img.image = render
img.place(x=0,y=0)
window.mainloop()
However, this gives me the error:
TclError: image "pyimage3" doesn't exist
I have searched the forum with regard to this but could only find an answer relating to having several instances of Tk() in the code, but I simplified my code to just the above and it is not working.
The image is correctly named and contained within the same folder as the Python file. The same error occurs if I try it with a different image in JPEG or GIF format. The same error also occurs if I try putting several lines into one command. I have Pillow installed.