Where and when should I stop Timer object on window destruction

Dear all,

I’m writing a GUI using wx.Python Phoenix.

I have a timer obect calling custom wx.window descendant method. The wx.Window is not top-level. When I close the main window, it seems that timer continues working even after its parent window dies.

The python crashes. I tried intercepting EVT_CLOSE but it seems it doesn’t work for non-top level windows. Putting self.timer.Stop() in window’ del produces the exception:

Exception ignored in: <bound method LiveView.del of <live_view.LiveView object at 0x000001F92A2B1C18>>

Traceback (most recent call last):

File “c:\Auriga\halibut\app2\live_view.py”, line 337, in del

File “c:\Auriga\halibut\app2\live_view.py”, line 342, in on_close

RuntimeError: wrapped C/C++ object of type LiveView has been deleted

So, when and where should I stop my timer?

Best Regards,

Alexander Ivanenko