tkinter.TclError: image "pyimage3" doesn't exist tkinter.TclError: image "pyimage3" doesn't exist tkinter tkinter

tkinter.TclError: image "pyimage3" doesn't exist


I found the issue so figured I'd answer myself for anyone who has this issue in the future.

When the wlcm_scrn runs procedurely it is the only window that exists at that point in time, and so it can use tkinter.Tk(). The error arises because the button that calls the function is itself sitting in an active window that is also running as Tkinter.Tk(). So when Python/Tkinter tries to build wlcm_scrn from the button, it's essentially trying to create two windows under root and falling over.

The solution:

Changing line...

wlcm_scrn = tkinter.Tk()

to this...

wlcm_scrn = tkinter.Toplevel()

...stops the error, and the image shows.

I personally am going to have two instances of the function. One called procedurely under Tk(), and one called within the application under TopLevel().


The PhotoImage method creates an image for the first TK () instance created.Thus, it seems to have solved to inherit TK () instance by replacing TopLevel ().

This can be solved by specifying the master of the Tk () instance as the option of PhotoImage.

I think this should be changed.:

splsh_img = tkinter.PhotoImage(file=file,master=wlcm_scrn)


Maybe not for this exact case, but for a similar one, I found that the customary

if __name__ == '__main__':    wlcm_scrn()  #Call through procedure.

solves the problem as well. This seems to kill the active window and to create a new one each time you re-call the same module.