[vtkusers] wxPython & VTK: How to Destroy wxVTKRenderWindow without errors?

Charl Botha c.p.botha at tudelft.nl
Fri May 9 16:25:39 EDT 2008


On Fri, May 9, 2008 at 7:18 PM, Kenneth Evans <evans at aps.anl.gov> wrote:
>  So, the question is how do you remove and replace a wxVTKRenderWindow
>  properly.

The problem is that VTK reference counts everything and WX doesn't.
So you have to be careful to disconnect all VTK and WX elements and
then also make sure that all VTK bindings (refs in C++) disappear.
Importantly, get the renderwindow to release its graphics resources.

This all comes down to the following SuperSafe(tm) approach:

# remove all actors from the renderer
ren.RemoveAllViewProps()
# get rid of your binding
del ren
# get the renderwindow to release all system resources (including
opengl context)
wxRWI.GetRenderWindow().Finalize()
# break link between RWI and RW
wxRWI.SetRenderWindow(None)
# get rid of our binding
del wxRWI
# now you can destroy the containing wx Window
wxWin.Destroy()

Good luck,
Charl

-- 
http://visualisation.tudelft.nl/CharlBotha



More information about the vtkusers mailing list