Hide a dialog without destroying – pygtk one-liner

Keep the standard window decorators without having to create your own buttons to handle custom events. Closing a dialog without destroying it is a simple one-liner in pygtk.

dialog.connect("delete-event", \
        lambda w, e: dialog.hide() or True)

This is helpful when you have logic that replaces individual widgets inside a dialog and you don’t want to recreate the whole dialog. The user is still allowed to close the dialog without destroying the child widgets and you don’t need to go through the hassle of unparenting children or any complicated logic.

Now I can keep referring solely to the child objects and get ahold of their parent dialog details through calls to widget.get_parent.

Posted by admica   @   2 September 2011

Related Posts

0 Comments

No comments yet. Be the first to leave a comment !
Leave a Comment

Name

Email

Website

*

Previous Post
«
Next Post
»
Powered by Wordpress   |   Lunated designed by ZenVerse

Valid XHTML 1.0 Transitional