# Running python VTK examples inside paraview

**URL:** https://discourse.paraview.org/t/running-python-vtk-examples-inside-paraview/4748
**Category:** Development
**Tags:** python, vtk
**Created:** [July 3, 2020, 1:00pm UTC](https://discourse.paraview.org/t/running-python-vtk-examples-inside-paraview/4748 "2020-07-03T13:00:48Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Mohamed\_Abdelkhalek](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mohamed_abdelkhalek/32/4384_2.png) [@Mohamed\_Abdelkhalek](https://discourse.paraview.org/u/Mohamed_Abdelkhalek)
#### Post date: [July 3, 2020, 1:00pm UTC](https://discourse.paraview.org/t/running-python-vtk-examples-inside-paraview/4748/1 "2020-07-03T13:00:48Z")

</div>

Hello, new member here. I wonder if there is a documented way for running pure VTK examples from within the paraview python console and/or programmable source/filters.

For example, something like this.

```
import vtk
cone = vtk.vtkConeSource()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(cone.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
window = vtk.vtkRenderWindow()

window.SetSize(500, 500)

interactor = vtk.vtkRenderWindowInteractor()
interactor.SetRenderWindow(window)

renderer = vtk.vtkRenderer()
window.AddRenderer(renderer)

renderer.AddActor(actor)
# Setting the background to blue.
renderer.SetBackground(0.1, 0.1, 0.4)

window.Render()
interactor.Start()

```

Currently, although this works, it creates a new pyqt window on mac os. I wonder, if there is a documented way or examples to link this to paraview views and objects ?.

Thank You.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [July 3, 2020, 1:06pm UTC](https://discourse.paraview.org/t/running-python-vtk-examples-inside-paraview/4748/2 "2020-07-03T13:06:58Z")

</div>

This is not supported at all.

You can run _part_ of a VTK examples in a ProgammableSource (eveyrthing but the rendering part), although I’m not sure to see the point.

---

<div class="post-metadata">

### Author: ![Mohamed\_Abdelkhalek](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mohamed_abdelkhalek/32/4384_2.png) [@Mohamed\_Abdelkhalek](https://discourse.paraview.org/u/Mohamed_Abdelkhalek)
#### Post date: [July 3, 2020, 1:31pm UTC](https://discourse.paraview.org/t/running-python-vtk-examples-inside-paraview/4748/3 "2020-07-03T13:31:16Z")

</div>

Okay, there are just really powerful widgets for tracing contours, etc. On image data. In any case even if it runs in a separate window its not a big deal.

Then I assume I can retrieve the data from the interaction as vtk polydata or even numpy arrays and append them to a PV source or filter for example ?

Thanks

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [July 7, 2020, 12:52pm UTC](https://discourse.paraview.org/t/running-python-vtk-examples-inside-paraview/4748/4 "2020-07-07T12:52:18Z")

</div>

> In any case even if it runs in a separate window its not a big deal.

It is unsupported. Even if it works, it can break at any point.
