On Sat, Oct 06, 2007 at 03:07:01PM -0600, Seltzer wrote: > > I'm having some trouble getting a splash screen to work. > After looking around for a while, i found advice to do it like so: > > gtk.threads_init() > gtk.gdk.threads_init() > ... > sp = splash() > sp.do_show() > while gtk.events_pending(): > gtk.main_iteration() > gobject.timeout_add(9000, sp.destroy) > ... > main_window.show() > gtk.threads_enter() > gtk.main() > gtk.threads_leve() > ... > > The problem is that the program hangs when i get the the gtk.threads_enter() > part, > It works fine though if i don't have the statements about the splash screen. > > any ideas? > as an aside... do i need to wrap gtk.main() in threads enter/leave?
Do you _need_ threads, aside from the splash screen? Here's the framework that I'm using, roughly: class MyApp (parentclass_list): '''Class implementing your application logic''' def app_close (self): # cleanup here -- needed this method to close databases etc., # for some reason __del__ was not called on them if gtk.main_level() > 0: # needed if app_close is called explicitly gtk.main_quit() def create_app (splash, myargs): try: globals()['my_app'] = MyApp (myargs) except: # application initiation failed gtk.main_quit() raise splash.destroy() def main_init (): splash = gtk.Window (gtk.WINDOW_TOPLEVEL) # create splash contents here splash.realize() splash.window.set_type_hint (gtk.gdk.WINDOW_TYPE_HINT_SPLASHSCREEN) # needed because the window_type hint above does not work on Win32 :-/ splash.set_decorated (False) splash.set_position (gtk.WIN_POS_CENTER) splash.show_all() gobject.idle_add (create_app, splash, myargs) gtk.main() if my_app: # some method asked called gtk.main_quit my_app.app_close() I probably got the splash-initiation-through-gobject.idle_add idea from the FAQ or mailinglist, a couple of years ago. The various exit points have grown on top of it during an application's lifetime, to handle all exit cases. And I also have a quit method in the application class that idle_add()s the app_close above -- found it to be most reliable that way. That quit method can then be called from various signal handlers or methods. HTH, Filip -- http://slider.rack66.net/~mechanix/blog/ _______________________________________________ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/