Get a different (non default) widget when using param in parameterized class (holoviz param panel)

☆樱花仙子☆ 提交于 2019-12-11 17:34:05

问题


I use a parameterized class to build my Panel dashboard.

I would like to use a CrossSelector but this selector does not seem to be available when looking at the options that library Param gives. It only seems to have a ListSelector.

How do i get this CrossSelector using Param?

import param
import panel as pn

pn.extension('bokeh')

class ValveExplorer(param.Parameterized):

    selected_features = param.ListSelector(
        default=[1, 3],
        objects=[1, 2, 3, 4],
    )

# show list selector
pn.Row(valve_explorer.param['selected_features'])

This results in the following default ListSelector but I don't want this one. I would like to get a CrossSelector instead:


回答1:


Param has a default widget for every Selector, but you can change this.

You can override this default widget as follows to get the CrossSelector in your example by using pn.Param():

pn.Row(pn.Param(
    valve_explorer.param['selected_features'], 
    widgets={'selected_features': pn.widgets.CrossSelector}
))

See more documentation on using Param with Panel here:
https://panel.pyviz.org/user_guide/Param.html



来源:https://stackoverflow.com/questions/57943569/get-a-different-non-default-widget-when-using-param-in-parameterized-class-ho

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!