I wanted some results written to a file when the user quit the program.
Now I have solved the problem, but I'm wondering why the first approach
didn't work.
My first approach was to have a __del__ method for my, from wxPanel
derived, class that would write the necessary things to file. But that
didn't seem to work. At least a simple print statement in that method
didn't show up.
Has this to do with wxPanel just being a wrapper for wxPanelPtr kind
of thing or is something else involved?
I wanted some results written to a file when the user quit the program.
Now I have solved the problem, but I'm wondering why the first approach
didn't work.
My first approach was to have a __del__ method for my, from wxPanel
derived, class that would write the necessary things to file. But that
didn't seem to work. At least a simple print statement in that method
didn't show up.
Has this to do with wxPanel just being a wrapper for wxPanelPtr kind
of thing or is something else involved?
When the C++ object for the panel is destroyed then the __class__ of the Python instance is replaces with a class (_wxPyDeadObject) that raises an exception upon any attribute access, so in effect, your __del__ is no longer associated with the instance and so when the instance is destroyed it won't be called.
I have an item on my ToDo list to allow the __del__ of the original class to still be called, but it's not implemented yet.
UPDATE: I've just implemented it so it will be there in the next release.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!