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

Hi, My wx application work as expected but on exit dont destroy Timer object which calling StaticText. Object still running and doing console errors as in subject.
Im trying many routines as OnClose(event): self.Destroy() without effect.
How to destroy wx application without errors?
Regards,
Milos

Hi Milos,

I am not familiar with the details of wxPython; as far as I know wxPython just is a Python wrapper for wxWidgets, which is written in C++.

Said C++ parts probably are imported in Python using shared libraries resp. DLLs or alike. From Python you cannot delete C++ objects of such a library directly - you just can call API-functions of said libraries.

If there is no API-function which does the job, it might be the only way to kill the belonging process. Are you working on Windows, macOS or Linux?

There might be an alternative solution e.g. with delaying the destruction of the StaticText object or alike - can you please provide some code-snippets?

Cheers, Dominik

I had probably incorrectly binded frame event, following code work for me:

class MyFrame(wx.Frame):
    def __init__(self, *args, **kwds):
self.Bind(wx.EVT_CLOSE, self.OnClose)

def OnClose(self, event):
self.Destroy()

Thanks for interest
Milos

1 Like

Please repost your question to https://discuss.wxpython.org/