2009-06-24 135 views

回答

6

您需要將DeleteEventArgs.RetVal設置爲true,而不是false。從relevant Mono documentation

爲了保持Gtk.Window從封閉,設置Gtk.DeleteEventHandlerGtk.DeleteEventArgs.RetValtrue

+0

謝謝!它不是很清楚...... – Pisu 2012-05-20 12:48:23

0

從快速谷歌搜索發現,這條巨蟒的例子(link):

# When the window is requested to be closed, we need to check if they have 
# unsaved work. We use this callback to prompt the user to save their work 
# before they exit the application. From the "delete-event" signal, we can 
# choose to effectively cancel the close based on the value we return. 
def on_window_delete_event(self, widget, event, data=None): 

    if self.check_for_save(): self.on_save_menu_item_activate(None, None) 
    return False # Propogate event 

希望這有助於。

+1

將DeleteEventArgs.RetVal設置爲false可防止應用程序退出,但窗口仍然消失,並調用ShowAll不會再顯示它。 – weiqure 2009-06-26 18:35:24