Chris Hare wrote: > Thanks Peter. I threw away what I started with and merged your code into > my class: > > class externalLoopDisplay: > > def show(self): > main.logging.debug("externalLoopDisplay.show:","start") > > self.window = Tk() > > self.btnClose = Button(self.window, text="Close", > command=self.window.destroy, > bg=backColor,highlightbackground=warnColor, > highlightcolor=okColor) self.btnClose.grid(row=0, column=2) > self.label = Label(self.window) self.label.grid(row=1, column=0, > columnspan=3) > dirName = getRadarPath() + "/net" + str(netNumber.get()) # e.g. > .../Radar/net17/net17-YYYYMMDDHHMMSS.gif > self.imagefiles = glob.glob(dirName + "/*.gif") > self.imagefiles = cycle(self.imagefiles) > self.window.after_idle(self.next_image) > > def next_image(self): > imagefile = next(self.imagefiles) > image = Image.open(imagefile) > > w, h = image.size > image = image.resize((600, 550*h//w)) > > self.label.image = self.label["image"] = > ImageTk.PhotoImage(image=image) # <==== bails here > self.window.title("Now showing %s" % os.path.basename(imagefile)) > > self.window.after(2000, next_image) > > > I marked where the code bails with an error saying pyimage2 doesn't exist. > All of the images exist and worked just fine with your standalone script. > > Suggestions?
Google says you are calling Tkinter.Tk() more than once where you should instead use Tkinter.Toplevel(). As you didn't post that part of the code it's hard to verify, but when I add a second root = tk.Tk() to my example script I get a very similar exception: Exception in Tkinter callback Traceback (most recent call last): File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1413, in __call__ return self.func(*args) File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 498, in callit func(*args) File "cycle_image.py", line 16, in next_image label.image = label["image"] = ImageTk.PhotoImage(image=image) File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1212, in __setitem__ self.configure({key: value}) File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1205, in configure return self._configure('configure', cnf, kw) File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1196, in _configure self.tk.call(_flatten((self._w, cmd)) + self._options(cnf)) TclError: image "pyimage1" doesn't exist By the way: for future posts please remember to cut and paste the traceback, don't paraphrase the error message. Peter -- http://mail.python.org/mailman/listinfo/python-list