问题:小工具'A'是在MainWindow'B'中单击按钮后显示的顶级窗口。我如何指定一个处理程序来处理在单击Widget'A'的窗口边界'X'后发回的信号(参见下面的当前实现)?
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()
答案 0 :(得分:1)
delete_event
信号的处理程序必须返回True
才能阻止Window在关闭时被永久销毁。
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
如果您只想隐藏窗口,可以使用内置快捷方式:
self.widget_a.connect('delete_event', self.widget_a.hide_on_delete)