FAQ Index - Search - Recent Changes - Everything - Add entry

<< Previous Entry | FAQ Entry 20.5 | Next Entry >>

20.5. I want to show a splash screen and make it disappear. How?

Pablo Endres Lozada presented this question. I'd suggest using a timeout handler that calls hide() on the window. Something like:

 def setup_app(*args):
   main = gtk.Window()
   # [...] set main up

 splash = gtk.Window() 
 # [...] set splash up
 splash.show()
 # ensure it is rendered immediately
 while gtk.events_pending():
   gtk.main_iteration()

 gobject.timeout_add(5000, splash.hide) # 5*1000 miliseconds
 gobject.idle_add(setup_app)
 gtk.mainloop()
5 seconds later, the splash screen should hide. You should tie the setup portion of your application inside an idle handler (or use a similar technique) or you will end up doing all the work before the splash screen shows up, mind you.

PyGTK FAQ Wizard | PyGTK Homepage | Feedback to faq at pygtk.org