'image “pyimage2” doesn't exist'?

后端 未结 2 1784
失恋的感觉
失恋的感觉 2021-01-01 04:49

This is where the error is found:

global backbuttonimg
backbuttonimg = PhotoImage(file=\"backbutton.gif\")
C6 = tkinter.Button(W_CheckDates, image=backbutton         


        
相关标签:
2条回答
  • 2021-01-01 05:13

    Ok so you say that the login function works once, then it can't work again. Here the problem can be solved using tk.Toplevel() instead of tk.Tk() see: why python photoimages don't exist? and tkinter.TclError: image "pyimage3" doesn't exist

    These threads mention how you can't have two instances of Tk() running simultaneously, you have to use Toplevel() instead.

    Why did these threads not apply to you (i think they do...)? But just a tip, if you state that they don't apply to you, then give reasons why, it helps make your question clearer. Also, add the full traceback when your question is about a particular error.

    Hope this helps a bit.

    0 讨论(0)
  • 2021-01-01 05:23

    Adding this for anyone who has tried the above with no success. If you have an erroneous path when running the script in some environments the path to the file is retained. I commented out everything from where I first use PhotoImage up to the window mainloop, run the script, close resulting gui, uncomment the code, run, and it shows the image as expected.

    0 讨论(0)
提交回复
热议问题