parameters - Panel + Param 自定义 MultiFileSelector 小部件
问题描述
我尝试将 MultiFileSelector 参数转换为可以交互的小部件,但失败了。在本教程中,我尝试了以下方法。
class CustomExample(param.Parameterized):
f = param.MultiFileSelector()
pn.Param(CustomExample.param, widgets={ 'f': pn.widgets.Multiselect})
但我得到了错误,
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-11-bb344c131fb8> in <module>
5 #select_number = param.Selector(objects=[0, 1, 10, 100])
6
----> 7 pn.Param(CustomExample.param, widgets={ 'f': pn.widgets.Multiselect})
AttributeError: module 'panel.widgets' has no attribute 'Multiselect'
任何指针都会很棒。
解决方案
由于您使用的是param,因此在这种情况下,您必须检查哪个参数最接近您正在寻找的参数 param.MultiFileSelector:
class CustomExample(param.Parameterized):
file_selector = param.MultiFileSelector(path='*')
pn.Param(CustomExample.param['file_selector'])
这将显示以下多文件选择器:
如果要更改为不同的非默认选择器,可以这样做:
class CustomExample(param.Parameterized):
file_selector = param.MultiFileSelector(path='*')
pn.Param(
CustomExample.param['file_selector'],
widgets={'file_selector': pn.widgets.CrossSelector},
))
结果选择器:
您已经找到了这个文档: http: //panel.holoviz.org/user_guide/Param.html
但也许也看看这些 SO-questions:Get a different (non default) widget when using param in parameterized class (holoviz 参数面板)在 hvplot/holoviews/panel 对象中更改小部件类型的最佳方法是什么?
推荐阅读
- r - “mlp”和“mlpML”之间的区别
- swift - 如何从表格视图单元格中获取值
- javascript - 将 JSfiddle 转换为实际网站 - 随机图像生成器网站
- python - 如果值为 1,则更改整行的 PandasDF 值
- sql - 即使其中一张表在 oracle 中没有记录,也可以比较两张表之间的计数
- php - 奇怪的 PHP 循环范围我错过了什么?
- react-native - React Native - 如何将 Promises 与异步一起使用
- c# - 如何在 C# 中的标签中仅显示日期
- python - 定量数据集的意义测试(Python Pandas)
- python - sklearn 火车测试按年份划分