__del__ in wx.Frame?

Hi,

The class wx.Frame (eg) have not a __del__ method.
Is there any (valid) reason for this?

Possible usage:

class MyFrame(wx.Frame):

        def __init__(...)
            ...
        def __del__(...)
            ...
            self.Destroy()

f = MyFrame(...)
del f

Any trick to achieve this?

Jean-Michel Fauth, Switzerland

AFAIK, __del__ shouldn't be used, ever. Instead, use f.Destroy() when
you want to destroy it, and catch the OnDestroy event.

···

On Wed, 25 Aug 2004 16:21:57 +0200, Jean-Michel Fauth <jmfauth@bluewin.ch> wrote:

Hi,

The class wx.Frame (eg) have not a __del__ method.
Is there any (valid) reason for this?

Possible usage:

>>> class MyFrame(wx.Frame):
        def __init__(...)
            ...
        def __del__(...)
            ...
            self.Destroy()
>>> f = MyFrame(...)
>>> del f

Any trick to achieve this?

Also read this:
http://www.python.org/doc/faq/programming.html#my-class-defines-del-but-it-is-not-called-when-i-delete-the-object

IOW, there are many situations when your Destroy() in __del__ is not
going to do what you want it to.

···

On Wed, 25 Aug 2004 16:32:08 +0200, Vladimir Gritsenko <vladimir.gritsenko@gmail.com> wrote:

On Wed, 25 Aug 2004 16:21:57 +0200, Jean-Michel Fauth > <jmfauth@bluewin.ch> wrote:
> Hi,
>
> The class wx.Frame (eg) have not a __del__ method.
> Is there any (valid) reason for this?
>

AFAIK, __del__ shouldn't be used, ever. Instead, use f.Destroy() when
you want to destroy it, and catch the OnDestroy event.

--
charl p. botha http://cpbotha.net/ http://visualisation.tudelft.nl/

Jean-Michel Fauth wrote:

Hi,

The class wx.Frame (eg) have not a __del__ method.
Is there any (valid) reason for this?

Possible usage:

class MyFrame(wx.Frame):

        def __init__(...)
            ...
        def __del__(...)
            ...
            self.Destroy()

f = MyFrame(...)
del f

Any trick to achieve this?

The __del__ method will only be called when there are no more references to the object, which may or may not be true when the del statement is executed. In fact, in the case of wx.Frame it will never be true since the C++ object is holding a reference to the Python object. So __del__ will not be called until the C++ object is destroyed, and so at that point there will certainly be no need to call self.Destroy!

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!