Animating gifs in Tkinter

dwolff567 at my-deja.com dwolff567 at my-deja.com
Thu Jul 29 16:33:18 EDT 1999


Hello,

Has anyone had success with animating gif files using tkinter?
I have searched around and haven't found any example code for this.
My program runs a simulation in C which outputs a gif file every
once in a while.  The C program then calls a python method which
updates the gif file in a canvas widget.  I have had lots of trouble
with this for some strange reason.  The program will freeze at random
times, but only when
the picture is being updated.  Here is the code which updates the
image:

 def update(self,time):
        if(self.image == self.image1):
            self.image2 = PhotoImage(file="plot.gif")
            self.image = self.image2
        else:
            self.image1 = PhotoImage(file="plot.gif")
            self.image = self.image1
        self.simCanvas.delete(self.curImage)
        self.curImage =  self.simCanvas.create_image(0,0,anchor=NW,
                         image=self.image)

        self.simCanvas.update_idletasks()

I had to use two seperate PhotoImage instances or it wouldn't work at
all.

If anyone can be of any help, I would greatly appreciate it.  I would
also appreciate any example code you could send me.

Thanks,

  Dave


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




More information about the Python-list mailing list