[pygtk] exiting app
Neil Dugan
pygtk at butterflystitches.com.au
Mon Feb 11 09:51:57 WST 2008
Martin Bilek wrote:
> hi all,
> i make an window and connect to function.
>
> win = gtk.Window()
> win.connect("destroy", exitApp)
> gtk.main()
>
> def exitApp(*args))
> dlg = gtk.MessageDialog(type=gtk.MESSAGE_WARNING,
> buttons=gtk.BUTTONS_OK)
> dlg.set_markup("Please use Exit from Filemenu instead")
> dlg.run()
> dlg.destroy()
> return
>
> but after clicking on window close button window dissapear and showing
> only message dialog.
> how i make main window still visible ?
> thanks
Connect to the 'delete-event' and return True/False
window.connect("delete_event", self.delete_event)
window.connect("destroy", lambda wid: gtk.main_quit())
def delete_event(self,a,b) :
dialog = gtk.MessageDialog(self.window, gtk.DIALOG_MODAL,
gtk.MESSAGE_QUESTION,
gtk.BUTTONS_YES_NO)
dialog.set_markup("<big>Exit ?</big>")
result = dialog.run()
dialog.destroy()
return (result == gtk.RESPONSE_NO) # return False to exit
Regards Neil.
More information about the pygtk
mailing list