[vtkusers] wxPython & VTK: How to Destroy wxVTKRenderWindow without errors?
Kenneth Evans
evans at aps.anl.gov
Mon May 12 15:24:18 EDT 2008
Charl,
>> Do you see now?
No. I get an exception. I also get an exception in the following line from
your original solution:
wxRWI.SetRenderWindow(None)
i.e. Exception destroying renWin
'wxVTKRenderWindow' object has no attribute 'SetRenderWindow'
OK, I think I see the problem. I typically use a vtkRenderWindow and not a
vtkRenderWindowInteractor. I translated your fix to use wxVTKRenderWindow
(what I use). It does not have that method. vtkRenderWindowInteractor
apparently does, even though you can't find it through pattern searching. I
am not exactly a Python guru and did not know about __getattr__. So I
[somewhat] see, now. Clever. (But makes hard-to-follow code).
When I did use a vtkRenderWindowInteractor was in trying to modify the
cone6.py turorial example (VTK_DIR\Examples\Tutorial\Step6\Python) to use
WX. That did not work:
a. If I modified it to use:
iren.SetRenderWindow(self.renWin)
it fails with
iren.SetRenderWindow(self.renWin)
ValueError: method requires a VTK object
(which is a different exception, sorry).
b. If I modify it to use:
iren.SetRenderWindow(self.renWin.GetRenderWindow())
it doesn't get an exception, but it doesn't work right either.
c. If I just replace the wxVTKRenderWindow with a
wxVTKRenderWindowInteractor everywhere, it works fine.
I apologize that in doing all this trial and error, I may have got confused
about which class had what methods and what exceptions.
>> You're supposed to use either one or the other, not both.
So, that seems to work, once you know the rule. However, the cone6.py
example (VTK_DIR\Examples\Tutorial\Step6\Python) doesn't do that. (It's not
that I especially care about cone6.py, but it is a standard example that
everyone has.)
What happens when you have more than one interactor?
In any event I've learned a bit. Thanks. Sorry if I've been a pain in the
butt.
-Ken
More information about the vtkusers
mailing list