On Fri, Aug 15, 2003 at 11:33:24PM +0100, Gustavo J A M Carneiro wrote: > > for i in range(1, 100): > > my_silly_label.set_text(s[i % 4]) > > time.sleep(0.1) > > > > In this example `my_silly_label' (which is a `Label' as you might > > guess :) doesn't get refreshed in the loop, but right after that. > > No, this woudn't work. You have to use timeouts. When calling > time.sleep(), gtk becomes blocked and doesn't update the gui. Some code > to do what you want would be: > > def timeout_func(data): > itr, label = data > i = itr.next() > label.set_text(s[i % 4]) > return True > gobject.timeout_add(100, timeout_func, (iter(xrange(1, 100)), label))
Another (simpler) option would be to call gtk.mainiteration() before the time.sleep() -- the FAQ has an entry on this. Take care, -- Christian Reis, Senior Engineer, Async Open Source, Brazil. http://async.com.br/~kiko/ | [+55 16] 261 2331 | NMFL _______________________________________________ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
