image

Fredrik Lundh fredrik at pythonware.com
Tue Nov 8 04:36:53 EST 2005


> >  File "C:\Python23\lib\lib-tk\Tkinter.py", line 2882, in image_create
> >    return self.tk.call(
> > TclError: image "pyimage4" doesn't exist
>
> works for me, when running it from a stock CPython interpreter.
>
> have you tried running the script outside the pywin environment?

btw, the error message indicates that the problem is that PythonWin
doesn't clean things up between runs, so you end up creating new Tk
objects every time you try the script.  but when you call PhotoImage,
it uses the default root window (which was created the first time you
called Tk), so you get back an image that's associated with another
Tk instance.

it's really an issue with PythonWin, but if you cannot switch to an IDE
that runs your scripts in a separate process, you can work around the
problem by passing in an explicit master to the PhotoImage factory:

    photo=PhotoImage(file='...', master=root)

</F>






More information about the Python-list mailing list