On Thu, 24 Mar 2005 06:21:36 GMT, Alex VanderWoude <[EMAIL PROTECTED]> wrote: > I am attempting to save my window's size and position when it closes. So I > figured I'd put some code in the __del__() method: > > from wxPython import * > class MyWindow(wxFrame): > def __init__(self, parent, id=wxID_ANY, title=None, style=None): > # Some stuff here. > def __del__(self): > x, y = self.GetPositionTuple() > width, height = self.GetSizeTuple() > # Store the values in a file or something. > wxFrame.__del__(self) > > However, when I run this code I end up with an unhandled exception on the > first line in __del__(). Apparently you can't call GetPositionTuple() (or > GetSizeTuple() for that matter) in __del__(). I'm confused by this, because > I thought that __del__() was called before the object was actually > destroyed. I can still do a dir(self), so obviously not everything > associated with my instance is gone. Or does that work because it's part of > the class, not just my instance? Any insight into this would be greatly > appreciated.
Don't use __del__, use EVT_CLOSE i.e. self.Bind(wx.EVT_CLOSE, self.OnClose) and def OnClose(self, evt): x, y = self.GetPositionTuple() -- Stephen Thorne Development Engineer -- http://mail.python.org/mailman/listinfo/python-list