Consider the following script
import vtk
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
an_actor = vtk....
ren.AddActor(an_actor)
iren.Initialize()
renWin.Render()
iren.Start()
If the script ends, everything will be fine and the created window will be closed, and resources will be freed when the window is manually closed (click X) or press the exit key (Q or E).
However, if there are more statements, you will notice that the window still exists, which is understandable, because we did not call anything to refuse it, just ended the interaction cycle.
See for yourself by adding the following:
temp = raw_input('The window did not close, right? (press Enter)')
According to VTK / Examples / Cxx / Visualization / CloseWindow , this
iren.GetRenderWindow().Finalize() # equivalent: renWin.Finalize()
iren.TerminateApp()
must do the job, but itβs not.
What else do I need to do to close a programmatically open window?
source
share