Carl’s approach is good too, but if you want to stay closer to your original example, the key is that inside the function, there’s no slider, just a value, so you don’t have to ask for the value. (The error message indicates that it’s already a tuple, not a slider whose value you need to request.) Panel’s depends
decorator is already taking care of pulling that value out and supplying it to the function. To make that clear, I’ve renamed your Slider
and Ensemble
names to be lower case (always reserving upper case for class names for clarity), and also renamed Slider
inside the function so that you can distinguish between the slider widget object (now called slider
) and the value of the slider (slider.value
, provided by Panel as a tuple called xrange
to the ensemble
function). Hope this helps!
import holoviews as hv
import panel as pn
from panel import widgets as pnw
import numpy as np
hv.extension('bokeh')
coords = np.random.rand(50,2)
points = hv.Points(coords)
slider = pnw.RangeSlider(start=0, step=0.1, end=1, name='Zeitraum')
@pn.depends(xrange=slider)
def ensemble(xrange):
points=hv.Points(coords)
points.opts(color='k', marker='+', xlim=xrange)
return pn.Row(points)
pn.Row(ensemble, slider)