I’m a new user of Panel, and I have a bound function created with pn.bind
, like this:
magnitude = pnw.IntSlider(end=10, name='value', value=5, value_throttled=5)
cmap = pnw.RadioButtonGroup(name='cmap', value='viridis',
options=['viridis', 'plasma', 'inferno', 'magma', 'cividis'])
boundfn = pn.bind(random_imshow, magnitude=magnitude, sigma=3, colormap=cmap)
pane = pn.Row(pn.Column(magnitude, cmap), boundfn)
This provides a slider and a radio button group, and the random_imshow
function is called with the right arguments each time any of these inputs change.
I would like to run this random_imshow
function every second, updating the display, and using as parameters the latest values from the UI.
I thought that adding:
pn.state.add_periodic_callback(boundfn, period=1000)
would work, but it doesn’t seem to get called every second.
I naively assumed this would work, and am a bit stuck now, and am not sure where to go next.
Is there a way to get Panel to call this bound function every second, updating the screen? Or would I have to go deeper into Panel and try and link some of the underlying objects together somehow? I liked the simple way that pn.bind
worked, and was hoping it would easily extend to refreshing regularly.
A full Jupyter notebook with my example code is available at https://nbviewer.jupyter.org/gist/robintw/f42abfe296795e253fb9abcd2215b4dd - and that includes the definition of random_imshow
which is not shown here for brevity.
Thanks,
Robin