[Tkinter-discuss] animated gif

Pavel Kosina geon at post.cz
Thu Jun 15 20:28:25 CEST 2006


Hi all,

How to animate an animated gif? I made some trials, using metod seek() 
on instance of Image.open, cause I believe Tkinter can not do this 
itself, but no success. My gif got 2 frames, and the second one is 
always more or less black.

This script is not "animated", just want to show my approach to the problem:

from Tkinter import *
from PIL import Image, ImageTk

hlavni=Tk()
platno=Canvas(hlavni)
platno.pack()

image = Image.open("myani.gif")
frames=[]
for frame in range(2):
    image.seek(frame)
    frames.append(ImageTk.PhotoImage(image))

platno.create_image(50,50, image=frames[0])
platno.create_image(100,100, image=frames[1])

hlavni.mainloop()

Thank you all for any suggestion.

-- 
geon
Pavel Kosina



More information about the Tkinter-discuss mailing list