[pygtk] hide on delete_event()
Frédéric
frederic.mantegazza at gbiloba.org
Fri Dec 19 18:39:46 WST 2008
Le 19/12/2008, "John Finlay" <finlay at moeraki.com> a écrit:
> Frédéric wrote:
>>
>> It seems that all documentation related to that point refer to gtk.Window
>> widgets, and it works fine. But if the main window opens a gtk.Dialog,
>> then, it is impossible to avoid this dialog to be destroyed when hitting
>> its X box: even if event-delete callback returns True, the signal is
>> propagated, and the destroy signal is emited.
>
>Could you create a small, self-contained program to illustrate the
>problem you are having?
Sure:
import gtk
def delete(widget, event):
print "delete()"
return True # Should not propagate delete-event
def destroy(widget):
print "destroy()"
return True
def clicked(widget):
print "clicked()"
dialog = gtk.Dialog("My dialog", win,
gtk.DIALOG_MODAL,
(gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
dialog.set_size_request(200, 50)
dialog.show()
dialog.connect("delete-event", delete)
dialog.connect("destroy", destroy)
dialog.run()
dialog.destroy()
win = gtk.Window()
win.set_size_request(200, 50)
button = gtk.Button("Open dialog...")
button.connect("clicked", clicked)
win.add(button)
win.connect("delete-event", gtk.main_quit)
win.show_all()
gtk.main()
--
Frédéric
More information about the pygtk
mailing list