# vtkRenderWindowInteractor on OSX

**URL:** https://discourse.vtk.org/t/vtkrenderwindowinteractor-on-osx/10667
**Category:** Development
**Created:** [February 13, 2023, 11:04pm UTC](https://discourse.vtk.org/t/vtkrenderwindowinteractor-on-osx/10667 "2023-02-13T23:04:51Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![marcomusy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/marcomusy/32/95_2.png) [@marcomusy](https://discourse.vtk.org/u/marcomusy)
#### Post date: [February 13, 2023, 11:04pm UTC](https://discourse.vtk.org/t/vtkrenderwindowinteractor-on-osx/10667/1 "2023-02-13T23:04:51Z")

</div>

The `vtkRenderWindowInteractor` class has some erratic behavior, on ubuntu I get a seg fault sometimes when interacting with the scene and pressing q at the same time. On OSX the rendering window doesn’t close unless another instance is created, eg:

```python
import vtk
import time

print("---- Start")
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

iren.Initialize()
renWin.Render()
iren.Start()

print("---- Finalize")
renWin.Finalize()
time.sleep(2)

print("---- TerminateApp")
iren.TerminateApp()
# del renWin, iren # no effect

# at this point the widown should be closed, but it's not.

ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.SetPosition(500,500)
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
iren.Initialize()
renWin.Render()
iren.Start() # THIS MAKES THE WINDOW CLOSE

time.sleep(2)

print("---- Exit")

```

```auto
# vtk version : 9.2.5
# python version : 3.10.8 (main, Nov 24 2022, 08:09:04) [Clang 14.0.6]
# python interpreter: /Users/mmusy/Software/miniconda3/bin/python
# system : Darwin 21.6.0 posix x86_64

```

---

<div class="post-metadata">

### Author: ![marcomusy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/marcomusy/32/95_2.png) [@marcomusy](https://discourse.vtk.org/u/marcomusy)
#### Post date: [February 14, 2023, 12:28am UTC](https://discourse.vtk.org/t/vtkrenderwindowinteractor-on-osx/10667/2 "2023-02-14T00:28:58Z")

</div>

… i just found a way out:

```python
import vtk
import time

print("---- Start (press q)")
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

iren.Initialize()
renWin.Render()
iren.Start()

print("---- TerminateApp")
iren.TerminateApp()
time.sleep(2)

print("---- Finalize")
renWin.Finalize()

iren.ProcessEvents()
time.sleep(2)

print("---- Exit")

```

this now works! it seems that event processing works differently on different os.
