在参数化类中使用param时,获取其他(非默认)窗口小部件(holoviz param面板) [英] Get a different (non default) widget when using param in parameterized class (holoviz param panel)
问题描述
我使用参数化的类来构建我的Panel仪表板.
I use a parameterized class to build my Panel dashboard.
我想使用 CrossSelector ,但这当查看Param库提供的选项时,似乎没有选择器.它似乎只有一个 ListSelector .
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.
如何使用Param获得此CrossSelector?
How do i get this CrossSelector using Param?
import param
import panel as pn
pn.extension()
class ValveExplorer(param.Parameterized):
selected_features = param.ListSelector(
default=[1, 3],
objects=[1, 2, 3, 4],
)
valve_explorer = ValveExplorer()
# show list selector
pn.Row(valve_explorer.param['selected_features'])
这将导致以下默认ListSelector,但我不希望出现此情况.我想改为使用CrossSelector:
This results in the following default ListSelector but I don't want this one. I would like to get a CrossSelector instead:
推荐答案
Param为每个选择器都有一个默认的小部件,但是您可以更改它.
Param has a default widget for every Selector, but you can change this.
您可以使用 pn.Param():
pn.Row(pn.Param(
valve_explorer.param['selected_features'],
widgets={'selected_features': pn.widgets.CrossSelector}
))
在SO上找到的类似解决方案正在使用pn.panel():
A similar solution found on SO is using pn.panel():
pn.Row(pn.panel(
valve_explorer.param['selected_features'],
widgets={'selected_features': pn.widgets.CrossSelector}
))
在此处查看有关将Param与Panel一起使用的更多文档:
https://panel.pyviz.org/user_guide/Param.html
See more documentation on using Param with Panel here:
https://panel.pyviz.org/user_guide/Param.html
这篇关于在参数化类中使用param时,获取其他(非默认)窗口小部件(holoviz param面板)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!