Running Python macro from C++

Hi!

Lately I have been experimenting with plugins and custom interfaces.
The basic idea is to have custom buttons in a toolbar that execute traced Python scripts.

As far as I am aware, filters with custom property widgets can be written in Python using the VTKPythonAlgorithmBase, but to really add new UI features one has to interact with Qt in C++. Please correct me if I’m wrong.

On the other hand, I don’t want to lose the ease of use of the existing feature like paraview.simple by completely working in C++. So is there a way to, for example, execute a Python macro once a custom button is pressed?

Currently I’ve looked at the pqPythonShell and pqPythonManager classes, but can’t seem to build a version that includes their headers. Tried building with PARAVIEW_USE_PYTHON=ON as well as VTK_MODULE_ENABLE_ParaView_pqPython=YES, but that did not help. Also looked at the PythonQt library, but that seemed outdated as it required Qt4.

Any ideas or suggestions for better approaches are welcome.

Kind regards,
Davis

This is correct

Tried building with PARAVIEW_USE_PYTHON=ON

Should be enough, but be sure to add the dependency in your plugin too.

Also looked at the PythonQt library, but that seemed outdated as it required Qt4.

Correct