python vtk: how to import QVTKOpenGLNativeWidget

I am using python based vtk, and I want to import QVTKOpenGLNativeWidget, but an error is reported:


AttributeError: module 'vtkmodules.all' has no attribute 'QVTKOpenGLNativeWidget'

How can I import QVTKOpenGLNativeWidget? Is it necessary to compile vtk from source code and then generate python module?

I don’t think that class is wrapped in Python.

Cc: @mwestphal @dgobbi

I dont think it is either.

Just curious, why don’t wrap it in python?

It is not a vtkObjectBase and the wrappers only understand how to wrap it and its subclasses. I suppose it could be wrapped with whatever Qt uses (it is a QObject), but that has not been implemented.

Exactly. In order to be used in Python, QVTKOpenGLNativeWidget would have to be wrapped with PyQt/sip and PySide/shiboken. In other words, wrapping this class is very different from wrapping other VTK classes, and it would require a lot of work.

That’s why people use QVTKRenderWindowInteractor.py instead. It is a pure Python class that doesn’t require QVTKOpenGLNativeWidget. Please see the example.

1 Like