I'm using a list of weakrefs to wx.Frames for a list of current active frames.
But, when a Frame is closed the weakref returns a _wxPyDeadObject instead None.
The weakrefs can do a callback when an object is deleted and i'm trying to use it to remove the frame in active frames list, but the callback is not raised because the weakref is alive.
How can avoid this problem?
Thanks
···
--
*****************************************
Oswaldo Hernández
oswaldo (@) soft-com (.) es
*****************************************
PD:
Antes de imprimir este mensaje, asegúrese de que es necesario.
El medio ambiente está en nuestra mano.
You can't, what you're doing can't work. It's for the same reason that
you can't attach a weakref to a file object and expect it to be called
when the file is closed.
The lifetime of a wxFrame is tied to the underlying C++ object
managment - the Python wx.Frame object is just a proxy for that. The
frame being destroyed doesn't delete references to it (there's no way
to do it in the python object model) any more than closing a file
deletes references to a file. Since the weakref mechanism is only for
refcounting, it's not suitable for this sort of notification.
wxApp actually maintains a list of top level windows, although it's
not exposed as an API. You might consider writing a patch.
···
On Wed, Feb 27, 2008 at 8:45 AM, Oswaldo Hernández <listas@soft-com.es> wrote:
Hello all,
I'm using a list of weakrefs to wx.Frames for a list of current active frames.
But, when a Frame is closed the weakref returns a _wxPyDeadObject instead None.
The weakrefs can do a callback when an object is deleted and i'm trying to use it to remove the
frame in active frames list, but the callback is not raised because the weakref is alive.