What to pass as 'view' for python_view.call_render function?

I’m trying to use a custom render function (call_render from the python_view module) for a PythonView instance. If I write a render(view, width, height) function in the Script tab, it works just fine.

Then I tried renaming my render function to render2 and the call_render call below it.
For example python_view.call_render(render2, view, 300, 300).
I don’t understand though what exactly should I pass as the view argument? It should be a vtkPythonView class instance, but how can I access it?

I tried something like FindView(“PythonView1”).SMProxy.GetClientSideView(), which technically returns vtkPythonView class, but this approach does not work.

I need this because it seems that multiple PythonView instances will all use the same render function, even if the code in each view’s Script window is completely different. Whichever render function was modified last is the one used to render all PythonViews. Thought that using custom render functions would solve this issue.

Looked at the source code of the vtkPythonView class, and it seems that call_render is not meant to be used from the PythonView’s Script window.

The code given in Script window is built into a Python module. Then vtkPythonView searches for a render function within this module, and the name of the function is hard-coded to “render”. Afterwards vtkPythonView class calls the python_view.call_render function, giving the pointer to itself as the view argument.

Ok. Got it. But why is the render function “shared” between multiple PythonViews in ParaView?

1 Like

Ah, you have uncovered an important bug with this implementation. Each view should have its own environment to prevent this problem.

I reported the problem here: https://gitlab.kitware.com/paraview/paraview/-/issues/21431