Picon

Confirm exit dialog

Hi everybody,
I'd like to know if there is any way to replace the destroy action over a window when you press the close button by another event, for example, just hiding it instead of destroying it, or show a confirm exit dialog before closing.
Thanks!

--
Lampar

Mudanza de blog en curso...

_______________________________________________
pygtk mailing list   pygtk <at> daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
Picon

Re: Confirm exit dialog

Ok, I've been researching a little more and I found out a magical function called hide_on_delete which you have to connect to the destroy_event in the desired window.
For example:

window = gtk.Window()
window.connect('destroy_event', window.hide_on_delete)

And it seems as if this function removes the default function linked to the window which destroys the window, and calls the hide() method of the window instead.

On Fri, Nov 14, 2008 at 3:38 PM, Braulio Ríos <braulioriosf <at> gmail.com> wrote:
Hi everybody,
I'd like to know if there is any way to replace the destroy action over a window when you press the close button by another event, for example, just hiding it instead of destroying it, or show a confirm exit dialog before closing.
Thanks!

--
Lampar

Mudanza de blog en curso...



--
Lampar

Mudanza de blog en curso...
_______________________________________________
pygtk mailing list   pygtk <at> daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
Picon

Re: Confirm exit dialog

Researching more and more I discovered that all you have to do, is the following:

window = gtk.Window()
window.connect('delete_event', hide)
def hide(widget, signal):
   widget.hide()
   return True

The key is that when you call the connect method, it connects this function before the default class signal handlers, and if the function returns True, the other handlers won't be called. If the handler doesn't return anything, or False, then all the following handlers will be called, for example, the destroy function which destroys the window, casually.



On Fri, Nov 14, 2008 at 4:10 PM, Braulio Ríos <braulioriosf <at> gmail.com> wrote:
Ok, I've been researching a little more and I found out a magical function called hide_on_delete which you have to connect to the destroy_event in the desired window.
For example:

window = gtk.Window()
window.connect('destroy_event', window.hide_on_delete)

And it seems as if this function removes the default function linked to the window which destroys the window, and calls the hide() method of the window instead.


On Fri, Nov 14, 2008 at 3:38 PM, Braulio Ríos <braulioriosf <at> gmail.com> wrote:
Hi everybody,
I'd like to know if there is any way to replace the destroy action over a window when you press the close button by another event, for example, just hiding it instead of destroying it, or show a confirm exit dialog before closing.
Thanks!

--
Lampar

Mudanza de blog en curso...



--
Lampar

Mudanza de blog en curso...



--
Lampar

Mudanza de blog en curso...
_______________________________________________
pygtk mailing list   pygtk <at> daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Gmane