| FAQ Index - Search - Recent Changes - Everything - Add 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):
window.hide()
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)
