# How to access QVTK... classes in Python

**URL:** <https://discourse.slicer.org/t/how-to-access-qvtk-classes-in-python/18521>\
**Category:** Development\
**Tags:** vtk, python, python-cli\
**Created:** [July 5, 2021, 3:41pm UTC](https://discourse.slicer.org/t/how-to-access-qvtk-classes-in-python/18521 "2021-07-05T15:41:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarineC](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@MarineC](https://discourse.slicer.org/u/MarineC)\
**Post date:** [July 5, 2021, 3:41pm UTC](https://discourse.slicer.org/t/how-to-access-qvtk-classes-in-python/18521/1 "2021-07-05T15:41:42Z")

</div>

Hi everyone !

I need to use a VTK function called QVTKOpenGLStereoWidget in Python.  
I saw a vtk example where they did this way :

```auto
from PyQt4 import QtGui
from vtk.qt4.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor

```

And then use it like this :

```auto
class MainWindow(QtGui.QMainWindow):

    def __init__ (self, parent=None):
        QtGui.QMainWindow. __init__ (self, parent)

        self.frame = QtGui.QFrame()
        self.vtkWidget = QVTKRenderWindowInteractor(self.frame)

```

However, after looking at some topics, it seems Slicer uses PythonQt and not PyQt.  
So in order to access my class, can I just remplace PyQt4 to PythonQt and qt4 with qt5, or do I need to do differently ?

Thanks for the help !

Marine

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [July 6, 2021, 2:16pm UTC](https://discourse.slicer.org/t/how-to-access-qvtk-classes-in-python/18521/2 "2021-07-06T14:16:14Z")

</div>

Normally you can access any VTK class in the main `vtk` module. Like `vtk.vtkCollection()`. However, this particular module seems not to be Python wrapped. I’d use the `vtkQWidgetWidget` class from the same module but also could not figure out how, so I added a C++ function using it directly that I then call form Python.

---

<div class="post-metadata">

**Author:** ![MarineC](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@MarineC](https://discourse.slicer.org/u/MarineC)\
**Post date:** [July 6, 2021, 3:00pm UTC](https://discourse.slicer.org/t/how-to-access-qvtk-classes-in-python/18521/3 "2021-07-06T15:00:14Z")

</div>

OK thanks for the infos I’ll do that ! 🙂
