0

I'm working on adding an image to a GUI interface using Tkinter. In order to eliminate as many factors as possible, I have stripped out everything but the parts relevant to adding an image, yet it still errors out with "tclError:image "pyimageX" doesn't exist" (where X a number). I have followed directly from a tutorial, and I've checked and double checked the file name, and that the file is directly inside the same folder as the program. I have no other ideas to check, and thus, here I am. Thanks for any help you can provide, I'm really hoping I'm not missing anything obvious.

Here's the snippet that's not working:

from tkinter import *
root =Tk()

versionNumRaw = PhotoImage(file="versionNum.gif")
versionNum = Label(root,image=versionNumRaw)
versionNum.pack()

root.mainloop()

Forgive me, as I know this sort of error has been posted before, with answers that have worked for others, but me, still being not having much experience with programming, cant figure out how to apply the answers others have gotten to my own case.

qwerty22
  • 101
  • 2
  • 6
  • 2
    This code snippet works fine. Also looking at the other questions like this, problem lies in having two `Tk()` instances at the same time. http://stackoverflow.com/questions/20251161/tkinter-tclerror-image-pyimage3-doesnt-exist http://stackoverflow.com/questions/12800007/why-python-photoimages-dont-exist http://stackoverflow.com/questions/23224574/tkinter-create-image-function-error-pyimage1-does-not-exist or like in this question trying to assign an image to text variable of `label`. http://stackoverflow.com/questions/20666545/python-3-3-tkinter-image-doesnt-exist – Lafexlos Jan 18 '15 at 10:34
  • So Im not sure whats going on, I tried to run it like 20 ties last night, and nothing worked, but you are correct, Its now working, and I dont know why. Thanks anyways. – qwerty22 Jan 18 '15 at 17:19
  • 1
    Going to put this here as it ended up being the "solution". It seems that what happened was that the program would start running, load some of the pictures, then crash. Id try again, and it would already be running or using some of the components. Either way, if I simply restarted the IDE, the issue resolved itself, but youll have to do this after every time you get the error. – qwerty22 Jan 19 '15 at 05:27

0 Answers0