[pygtk] Dialog Lifecycle?

Neil Dugan pygtk at butterflystitches.com.au
Wed Mar 19 23:57:21 WST 2008


Darren Hart wrote:
> I'm trying to add a dialog bound to a menu item.  I created the UI in
> glade.  I use the glade.XML.get_widget() to get the dialog, and then show()
> it from the menuitem action handler.  Then I hide it when the dialog
> response handler receives RESPONSE_OK.  If I CLOSE the dialog however (from
> the window manager X button) I see gtk.RESPONSE_DELETE_EVENT, and after that
> I can no longer use glade.XML.get_widget() to retrieve my dialog.  It has
> been destroyed.
> 
> 1) Is it really necessary to destroy and recreate the dialolg, rather than
> just show/hide?
> 2) If so, is the only way to recreate the dialog to re-read the glade file,
> passing it the dialog name as the third param?
> 
> Also, the dialog is visible by default, so part of my start -up sequence is
> to hide it.... but you can see the wm animation... so I don't think that is
> the right way either.
> 
> I get the feeling I'm swimming upstream here, so if someone can set me
> straight on how to properly use dialog boxes, I would be most appreciative.
> 
> Thanks,
> 
> 

Hi Darren,

The way I do it is, I have a function like.

def hide(self, dialog, event) :
	dialog.hide()
	return True

And in the init I use the command
	dialog.connect('delete_event', self.hide)

I am not using glade thou, but this should work.

Regards Neil.




More information about the pygtk mailing list