[vtkusers] [Python + wx] pb with wxVTKRenderWindow

Prabhu Ramachandran prabhu at aero.iitm.ernet.in
Fri Oct 4 15:08:00 EDT 2002


>>>>> "BR" == Benoit Regrain <benoit.regrain at creatis.insa-lyon.fr> writes:

    BR> I believe I might have found two bugs in the class
    BR> wxVTKRenderWindow as encountered in
    BR> VTK/Wrapping/Python/vtk/wx/wxVTKRenderWindow.py.  I am working
    BR> on Windows 2000 with the VTKNightly dated 10/02/2002.

    BR> I could fix this problem, by changing the line 164 by : try:
    BR> size = parent.GetSize() except: size = wxDefaultSize The
    BR> try/except is used to protect the call to parent.

2 points here:

 1. I think blanket except clauses are not a good idea (unless
 unavoidable).  I'd prefer something like:

try:
    size = parent.GetSize()
except AttributeError:
    size = wxDefaultSize

Or something like that.  I dont get an exception under Linux so don't
know what exception you are trying to catch here.  Could you care to
elaborate?
 
    BR>  - When the script wxVTKRenderWindow.py is launched and when
    BR> killing the window (by clicking on the window close button,
    BR> the one with a cross at the upper right), I get the following
    BR> error message in the Python console : runtime error R6025 -

    BR>    def __del__(self): renderers =
    BR> self._RenderWindow.GetRenderers() numRenderers =
    BR> renderers.GetNumberOfItems() self._CurrentRenderer = None
    BR> renderers.InitTraversal() for i in range(0,numRenderers):
    BR> self.GetRenderWindow().RemoveRenderer(renderers.GetNextItem())

This could be added but I have one question here.  IIRC __del__ is
actually called only after the window is killed and any "bad
behaviour" can occur when the window is alive.  Ok, there is the case
that the window is dead and the actors are still alive.  But are we
guaranteed that __del__ will be called as soon as the window is
destroyed?  The order of destruction of the objects also matters here.
I dont remember clearly but is there a way to always call a function
*before* a widget (I mean any widget) is destroyed and not at object
destruction?  If the renderers maybe removed in that function.

However, its been a while since I used wxPython so I cant remember the
exact thing to do.  Could any experienced wxPythoners comment on this?

cheers,
prabhu




More information about the vtkusers mailing list