当前位置: 代码迷 >> 综合 >> Bokeh:unexpected attribute ‘callback‘ to CheckboxGroup, similar attributes are js_event_callbacks
  详细解决方案

Bokeh:unexpected attribute ‘callback‘ to CheckboxGroup, similar attributes are js_event_callbacks

热度:55   发布时间:2023-12-15 17:26:32.0

使用Bokeh绘图出现如下报错

AttributeError: unexpected attribute 'callback' to CheckboxGroup, similar attributes are js_event_callbacks

 解决:

checkbox.callback = CustomJS(args=dict(l0=l0, l1=l1, l2=l2, checkbox=checkbox), code="""
l0.visible = 0 in checkbox.active;
l1.visible = 1 in checkbox.active;
l2.visible = 2 in checkbox.active;
""")

改为

callback = CustomJS(args=dict(l0=l0, l1=l1, l2=l2, checkbox=checkbox), code="""
l0.visible = 0 in checkbox.active;
l1.visible = 1 in checkbox.active;
l2.visible = 2 in checkbox.active;
""")
checkbox.js_on_change('active', callback)  # js_on_change的第一个参数为需要改变的参数

 

  相关解决方案