Updating pyvista plotter fails to update panel

73 views Asked by At

I'm using the panel package to render pyvista plotter objects. I am unable to get the pane.VTK ren_win to correctly update under the current version of panel. In addition, the example applications given in the panel repository also fail. I'm at a loss at this point.

Here's some simple code that illustrates the problem. The mesh renders correctly ONCE but when the plotter is changed via the button the pane appears to be the same:

import pyvista as pv
import panel as pn

# Create a PyVista plotter object
plotter = pv.Plotter()

# Add a mesh to the plotter
mesh = pv.Sphere()
plotter.add_mesh(mesh)

def update_plotter(event):
    # Update the plotter
    mesh.points[:, 0] += 0.3
    plotter.update()

# Create a VTK pane
vtk_pane = pn.pane.VTK(plotter.ren_win)

# Create a button to update the plotter
button = pn.widgets.Button(name='Update')
button.on_click(update_plotter)

# Create a Panel app
app = pn.Column(vtk_pane, button)

# Serve the app
app.servable()

0

There are 0 answers