[pygtk] hide on delete_event()

Neil Dugan pygtk at butterflystitches.com.au
Tue Dec 9 12:35:30 WST 2008


Peyman wrote:
> Hello
> 
> I am new to this mailing list. Originally I was posting to the glade  
> mailing list
> 
> My question is a simple one, I want my window to hide when I close it  
> (by clicking 'x'). I have browsed the web and the answer appears to be
> 
> def on_window_delete_event(widget,data,wtree):
> 		print "If you can read this, then everything should work fine"
> 
> 		widget.hide()
> 		return gtk.TRUE
> 
> But when I do this very exact thing it still gets destroyed. And later  
> when I call the drawingArea widget (inside the window) it claims there  
> is no such widget.
> 
> Anyone else run into this problem?
> 
> Thank You
> 
> 
> Peyman Askari

I use this, to hide my dialog

class MyDialog :
---cut---
   def __init__(self)
     self.window = gtk.Dialog(......)
     self.window.connect('delete_event', self.hide)
---cut---
   def hide(self, dialog=None, event=None) :
     self.window.hide()
     return True		# stop any event handling here
---cut---
   def show(self, callback = None):
     self.window.show()
---cut---

Regards Neil



More information about the pygtk mailing list