Hi,
I’m new to wxPython. The application I’m writing uses an MVC architecture. There is a Status_model that contains state information about the application. Then, there can be multiple Status_views that display this information. The Status_views register themselves with the model by calling an add_listener method. The Status_view is derived from wx.PyPanel. I’ve attached a stripped down Python outline.
The problem I’m running into is when the Status_view is destroyed, I’d like it to unregister itself by calling a remove_listener method of the Status_model. Otherwise when the Status_model changes it will try to update the destroyed/dead Status_view and and a PyDeadObjectError exceptions is raised.
I looked in the wxWidgets documentation. I see the wxWindow::Destroy method is virtual. so, I thought I could just implement a Destroy method in my Status_view class that calls the remove_listener method. But, that destroy method is never called. Surely, there is someway for a Window to find out that it is about to be destroyed so it can tie up some loose ends. I suspect that overriding the wxWindow::Destoy method is the way to do this in C++ applications. (Please correct me if this is wrong) But, I can’t figure out how to do this in Python. I’d appreciate any suggestions about a better way to do this.
Thanks,
Jeff
xxxx.py (1.19 KB)