Correct use of the Destroy Mechanism

Jenna Louis wrote:

Im confused about the purpose of the Destroy method. The wxWindows docs say that it delays the delete till wxWindows is ready. I see people calling and overloading it all the time but this seems dangerous especially when notebooks are involved because the DeletePage method deletes the object rather than calling Destroy and thus subsequent calls to Destroy fail and any cleanup code in the Destroy method is never called. Is there a way to make the notebook call Destroy or am I correct in thinking all cleanup code should just go in the __del__ method? Or is this simply a bug in the Notebook?

* Only the top-level windows will do a delayed delete when Destroy is called. All other window types just do a "delete this;" statement.

* Destroy is not overridable in Python such that calls to the C++ Destroy will get rerouted to the Python version. So unless you are explicitly calling Destroy from Python for that window overriding Destroy will do no good.

* By the time __del__ is called the C++ instance is already (or mostly) deleted, so be careful with accessing the instance.

* EVT_WINDOW_DESTROY should be sent a little earlier in the sequence than __del__ so that is an option too.

ยทยทยท

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