dlg.Destroy() behaviour

Jeff Shannon jeff at ccvcorp.com
Tue Feb 26 19:56:04 EST 2002


Duncan Smith wrote:

> "Cliff Wells" <logiplexsoftware at earthlink.net> wrote in message
> >
> > I don't know if this works (never tried it on a dialog), but
> dlg.SetFocus()
> > ?
>
> Thanks, but no.  A computer scientist mate of mine initially suggested that.
> It didn't work.  He then suggested I just got rid of dlg.Destroy(), which
> works, but he couldn't tell me whether it was a safe thing to do or not.  He
> suggested that as the 'deleted' dialogue wouldn't be destroyed immediately
> with dlg.Destroy() it might retain the focus.  I don't know.

As far as I understand it, you should be safe omitting the dlg.Destroy().  The
wxWindows dialog object *should* be cleaned up when the Python reference to it
goes out of scope.  If you're particularly worried about reclaiming memory as
soon as possible, then once the dialog is hidden (i.e., your dlg.ShowModal()
call returns), you should be able to 'del dlg', but I don't think that's
particularly necessary (especially if you re-use dlg for the next dialog).

If you are worried about memory leaks, use the hybrid build of wxPython.  At
program  end, it will dump a list of any leaked wxWindows objects.

Jeff Shannon
Technician/Programmer
Credit International





More information about the Python-list mailing list