How to set render function for each PythonView?

Hi,

I have two different PythonView’s, each with its own script. Each script contains a render function. I’d expect that each render function would update the view in which it is defined, but it seems that all views share the same render function definition.

For example, PythonView1’s script calls to render plot X. Afterwards, a different PythonView2’s script calls to render plot Y. The result is that both views contain plot Y. If PythonView2 doesn’t call to render anything, it will contain plot X. Why is that?

Kind regards,
Davis

Tried using the python_view.call_render function, which seems to be used exactly in cases like this, but a simple example (see below) fails. Nothing shows up and after a few clicks Paraview crashes.

import numpy as np
from paraview.simple import *
from paraview import python_view

def render2(view, width, height):
    print(view)
    figure = python_view.matplotlib_figure(width, height)
    ax = figure.add_subplot(1, 1, 1)
    x = np.linspace(1, 2*np.pi, 100)
    y = np.sin(x)
    ax.plot(x, y)
    figure.tight_layout()
    ax.grid()
    return python_view.figure_to_image(figure)
    # Width - 2081, height - 912

python_view.call_render(render2, view, width, height)

Edit: Fixed code formatting