tags:

views:

136

answers:

1

Hello,

I have a message box pop up when a certain operation is being executed sort of "wait..." window and I want to have a "loading" *.gif animation there to lighten up the mood :)

Anyways I can't seem to figure out how to make this work. What i have now is a code where img_wait is a gif but it wont animate. It only shows first frame. How can i combine these two codes to make it work?

    def yieldsleep(func):
    def start(*args, **kwds):
        iterable = func(*args, **kwds)
        def step(*args, **kwds):
            try:
                time = next(iterable)
                glib.timeout_add(time, step)
            except StopIteration:
                pass
        glib.idle_add(step)
    return start

class messageBox:
        def __init__(self, lbl_msg = '', dlg_title = '', img_wait = ''):
                self.wTree = gtk.glade.XML('msgbox.glade')

                self.wTree.get_widget('label1').set_text(lbl_msg)
                self.wTree.get_widget('dialog1').set_title(dlg_title)             
                self.wTree.get_widget('img_wait1').set_from_file(img_wait)

                self.wTree.get_widget("dialog1").set_keep_above(True)

        def done(self):
                self.wTree.get_widget('dialog1').destroy()       
class we:
        wTree = None
        def __init__( self ):                
                self.wTree = gtk.glade.XML( "main.glade" )             
                dic = {"on_buttonPopup" : self.popup}
                self.wTree.signal_autoconnect( dic )              
                gtk.main()

        @yieldsleep        
        def popup(self, widget, data=None):
                self.msg = messageBox('Wait...','','wait.gif')

                yield 1000
                print '1'
                yield 1000
                print '2'
                yield 1000
                print '3'

                self.msg.done()       
                self.msg = messageBox('Done!  ','','none.gif')
                yield 700             
                self.msg.done()

How can I modify the code above to work with:

zx = pyglet.resource.animation("wait.gif")
sprite = pyglet.sprite.Sprite(zx)    
win = pyglet.window.Window(width=100, height=100)

@win.event
def on_draw():
    win.clear()
    sprite.draw()

pyglet.app.run()

This code on its own shows the full animation of the gif file.

A: 

No one knows?

:(