Reputation: 2663
Problem: Widget 'A' is a toplevel window that is displayed after a button click in MainWindow 'B'. How do I assign a handler to handle the signal sent back after the 'X' along the window border of Widget 'A' is clicked (see below for current implementation)?
def on_mainWindow_B_button_clicked(self, widget):
self.widget_a.show()
def on_widget_a_destroy(self, widget): #this is the handler I have right now yet after it's called and widget.a closes and 'on_mainWindow_B_button_clicked' is called for the second time none of widget.a's children appear in the new window
widget.hide()
Upvotes: 0
Views: 477
Reputation: 536339
The handler for the delete_event
signal must return True
in order to stop the Window being permanently destroyed on closing.
self.widget_a.connect('delete_event', self.on_widget_a_delete)
def on_widget_a_delete(self, widget, event):
widget.hide()
# do something
return True
If you only want to have the window hide, there's a builtin shortcut you can use:
self.widget_a.connect('delete_event', self.widget_a.hide_on_delete)
Upvotes: 1