[pygtk] Animation
Steve McClure
sMcClure at racemi.com
Wed Oct 11 22:31:51 WST 2006
On Wed, 2006-10-11 at 09:23 -0500, Maximo Pech wrote:
> Hello, i'm new to pygtk and i'm trying to make a small animation using
> gtk.Image but i can't. This is my code:
>
> def animar(widget, lo_que_se_muestra):
> lo_que_se_muestra.set_from_pixbuf(frame1.get_pixbuf())
> lo_que_se_muestra.queue_draw()
> time.sleep(1)
You want to make sure all the queued events are processed here before
sleeping. You can insert something like this:
while gtk.events_pending():
gtk.mainiteration(False)
before your sleep.
However, I think the best way to do this is to use a timer to flip
through the frames, that way you know you get back to processing the
event queue. Lookup gobject.timeout_add() and its friends.
http://pygtk.org/pygtk2tutorial/ch-TimeoutsIOAndIdleFunctions.html#sec-Timeouts
> lo_que_se_muestra.set_from_pixbuf(frame2.get_pixbuf())
>
> frame1 = gtk.Image()
> frame2 = gtk.Image()
>
> frame1.set_from_file('/mnt/usb1/avatar1.png')
> frame2.set_from_file('/mnt/usb1/avatar2.png')
>
> lo_que_se_muestra = gtk.Image()
> bplay = gtk.Button('play')
> bplay.connect('clicked', animar, lo_que_se_muestra)
>
>
> The idea is to click the 'play' button, show the first frame, wait 1
> second and show the second frame, but what it is doing is wait 1
> second without showing nothing and then it shows only the last frame.
> _______________________________________________
> pygtk mailing list pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
--
Steve McClure Racemi
email: smcclure at racemi.com 380 Interstate North Pkwy, SE
voice: 404-892-5850 Suite 250
fax: 404-892-7215 Atlanta, GA 30339
http://www.racemi.com
More information about the pygtk
mailing list