Supporting panel widgets directly as streams
See original GitHub issueHoloViews supports turning parameters directly into streams such that DynamicMap
s update when parameter values change (the parameters are promoted to a Params
stream internally). Panel widgets are also based on param and I was hoping to use this support to drive a DynamicMap
with panel widgets. Unfortunately, as soon as you try to use more than one panel widget this way, you encounter name clashes as all widget value parameters have the same name (namely widget.param.value
).
Given that parameters can be used as streams, I would like to use param widgets directly as well, using the widget name (or some sort of identifier label which I think would be useful in Panel more generally e.g to select a specific widget out of a bank of widgets by name) as follows:
import panel as pn
import holoviews as hv
hv.extension('bokeh')
checkbox = pn.widgets.Checkbox(name='My Checkbox')
selector = pn.widgets.Select(options=['a','b','c'], name='My Selector')
def callback(my_selector, my_checkbox):
return hv.Curve([1,2,3])
hv.DynamicMap(callback, streams=[checkbox, selector])
This would be orthogonal to other approaches such as pn.bind
(which should also be available from param, without special widget support). For me this approach would feel very natural and I don’t think it precludes any other of the available approaches.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:9 (9 by maintainers)
Top GitHub Comments
One idea I quite like is to note that the streams parameter only supports lists for historical reasons:
Supporting a dict here would take a lot of the pain away imho and would be a great improvement for HoloViews generally (and would avoid the need for
bind
in many cases):Implementing this would make this issue mostly moot as this dict could support parameters or panel widgets as values (holoviews streams here become tricky for streams with multiple parameters).
Please file an issue about that. We do have a mechanism to query any panel object for subobjects matching some criteria using the
.select
method (modeled after bokeh’sModel.select
) and I would quite happily support for having anid
attribute or similar. The main concern here is that it cannot clash with any existing parameter in Panel.