[pygtk] Exiting an application with gtk.main_quit
John Finlay
finlay at moeraki.com
Mon Apr 21 02:07:22 WST 2008
Isaac Alston wrote:
> Hi,
>
> I've been trying to do the following: show a user/pass modal dialog
> before the user is allowed to use the main window with pygtk and
> glade3. If the user clicks 'cancel' then the dialog should also quit
> the application (because the user needs a valid login). I thought it
> would be as simple as binding the destroy event to gtk.main_quit;
> however, when I do this I get 'RuntimeError: called outside of a
> mainloop' and I'm not sure why. Here's my python code:
> http://dpaste.com/hold/45961 and here's auth_dialog.glade:
> http://dpaste.com/hold/45963 and main_window.glade:
> http://dpaste.com/hold/45964
>
You get the message because you are calling gtk.main_quit before you
call gtk.main from ad.run in line 35. If you check the return result
from ad.run and use it to decide whether to call gtk.main you can decide
whether the program continues or exits - no need to use the "destroy"
signal.
John
More information about the pygtk
mailing list