How to tell if the C++ part of a wxPython wrapper has already being deleted?

I couldnt find it.

Thanks,
Rodrigo

For most objects (those supported by "Original Object Return"):

if myWindow:
    blah()

should work. See the _wxPyDeadObject class in the wxPython.wx module.

HTH,
Mike

Rodrigo B. de Oliveira wrote:

···

I couldnt find it.

Thanks,
Rodrigo

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

--
_______________________________________
  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://members.rogers.com/mcfletch/

Rodrigo B. de Oliveira wrote:
> Subject: How to tell if the C++ part of a wxPython wrapper has
? already being deleted?

I couldnt find it.

When the C++ object has been deleted the Python instance's __class__ is repleaced with _wxPyDeadObject which has a __nonzero__ method so as Mike said you can just test the object:

  if !window:
    print "it's dead"

That class also raises a wxPyDeadObjectError for any attribute access, so operating normally but catching that exception will also let you know.

···

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

I am exactly encountering this issue. I know that my object has been deleted and the wxPyDeadObject has now come into the picture… is this something to do with how i have coded or is it do with WxPython?

···

On Thursday, January 23, 2003 10:10:25 AM UTC-8, Robin Dunn wrote:

Rodrigo B. de Oliveira wrote:

Subject: How to tell if the C++ part of a wxPython wrapper has
? already being deleted?
I couldnt find it.

When the C++ object has been deleted the Python instance’s class is
repleaced with _wxPyDeadObject which has a nonzero method so as Mike
said you can just test the object:

if !window:
print “it’s dead”

That class also raises a wxPyDeadObjectError for any attribute access,
so operating normally but catching that exception will also let you know.


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

I am using wxPython 2.8.12.1

···

On Monday, July 8, 2013 9:11:23 PM UTC-7, kb wrote:

I am exactly encountering this issue. I know that my object has been deleted and the wxPyDeadObject has now come into the picture… is this something to do with how i have coded or is it do with WxPython?

On Thursday, January 23, 2003 10:10:25 AM UTC-8, Robin Dunn wrote:

Rodrigo B. de Oliveira wrote:

Subject: How to tell if the C++ part of a wxPython wrapper has
? already being deleted?
I couldnt find it.

When the C++ object has been deleted the Python instance’s class is
repleaced with _wxPyDeadObject which has a nonzero method so as Mike
said you can just test the object:

if !window:
print “it’s dead”

That class also raises a wxPyDeadObjectError for any attribute access,
so operating normally but catching that exception will also let you know.


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