python wheel: How to compile the qt GUI for vtk’s git master version on Ubuntu 20.04.

Hi,

I try to compile the qt GUI for vtk’s git master version on Ubuntu 20.04 and use the following option:

cmake \
  -DCMAKE_INSTALL_PREFIX=/usr/local \
  -DCMAKE_INSTALL_RPATH=/usr/local/lib \
  -DVTK_WHEEL_BUILD=ON \
  -DVTK_WRAP_PYTHON=ON \
  -DVTK_GROUP_ENABLE_Qt:STRING=YES ..
make -j48
python setup.py bdist_wheel
make install

But after the installation, I don’t know how to invoking the vtk’s GUI. Any hints for this problem?

Reards

You could look at https://github.com/Kitware/VTK/blob/master/Wrapping/Python/vtkmodules/qt/QVTKRenderWindowInteractor.py

There are also examples available here by they are out of date: https://lorensen.github.io/VTKExamples/site/Python/Widgets/EmbedInPyQt2/

If you are using Python, then you do not have to enable Qt when you build VTK. You can use the plain vanilla VTK wheel. The “VTK_GROUP_ENABLE_Qt” setting is only needed if you want to use VTK’s C++ GUI classes, and it is irrelevant to the QVTKRenderWindowInteractor.py module that is used from Python.

Please try the following example and let me know if it works for you:
TestPyQtInteractor.py (2.4 KB)

1 Like

I try to run it as following but freeze there:

$ python ./lib/python3.8/site-packages/vtkmodules/qt/QVTKRenderWindowInteractor.py
PyQt5
^C

I use Ctrl + C and still cannot kill it.

Regards.

I run this example and it will display a multi-faces cone. But when I scale the GUI with mouse, the GUI fails to response and freezes there. As a result, the system stops to response for all keyboard’s commands and I must reset my computer.

Does this usage of vtk has high requirements for graphics cards or other computer resources?

Regards,
HY

There have been some changes in the code between VTK 8.2 and VTK 9. Which version of VTK are you using?

$ pip list | grep vtk
vtk                           9.0.20200612

This is from the wheel that you build yourself? If so, did you build it from VTK 9.0.0, or did get it from one of the git branches (either ‘master’ or ‘release’)?

On my system, with the VTK release branch (will be 9.0.1), I notice that the resizing of the VTK render window is a little bit delayed compared to the resizing of the Qt window for QVTKRenderWindowInteractor.py. I can imagine that this might cause instabilities, depending on the graphics driver (it has nothing to do with VTK’s GL requirements, it implies a bug either in QVTKRenderWindowInteractor.py or in VTK itself). I’m using the amdgpu driver.

Let me try again with the VTK master to see if it also has resizing issues with QVTKRenderWindowInteractor.py.

It’s built on vtk git master branch by me with the following cmake options:

cmake -DVTK_WHEEL_BUILD=ON -DVTK_WRAP_PYTHON=ON

Do you compile the gpu support into vtk? I don’t do any gpu relative compilation due that the graphical card for my case is very low-end.

The VTK build automatically links to the libOpenGL that exists on your system, and as far as I understand, libOpenGL automatically uses the GPU drivers that are installed. So, no, I did not do any GPU-specific configuration when I built VTK. It just uses my GPU automatically, via libOpenGL.

In any case, when I update to the VTK master branch (specifically, commit 06c1830867) I can reproduce the freeze. I have to resize the window a lot before the freeze occurs (around 30 seconds or so of continuous resizing), but I can definitely reproduce it. I didn’t see this in the release branch, but maybe I didn’t try hard enough.

I’ll look into this a bit deeper and get back to you (might take a while).