FAQ Index - Search - Recent Changes - Everything - Add entry

<< Previous Entry | FAQ Entry 10.21 | Next Entry >>

10.21. How to hide a window when clicking the close button (instead of destroying it)

Let's say you have a gtk.Window called window.

  def hide_window(window, event):
    return True

  window.connect('delete-event', hide_window)
The important bit is the return True in the callback, that prevents the window from being destroyed !

A more compact version would read:

   window.connect('delete-event', lambda w, e: w.hide() or True)

PyGTK FAQ Wizard | PyGTK Homepage | Feedback to faq at pygtk.org