【问题标题】:Getting error in bokeh button callback: unexpected attribute 'callback' to Button, similar attributes are js_event_callbacks在散景按钮回调中出错:按钮的意外属性“回调”,类似的属性是 js_event_callbacks
【发布时间】:2020-10-13 21:01:51
【问题描述】:

我在散景按钮回调中遇到错误:u按钮的预期属性“回调”,类似的属性是 js_event_callbacks。我从工作示例中复制:is there a way to save bokeh data table content。出现错误的代码如下:

savebutton.callback = CustomJS(
    args=dict(source_data=s1),
    code="""
        var inds = source_data.selected.indices;
        var data = source_data.data;
        var out = "x, y\\n";
        for (i = 0; i < inds.length; i++) {
            out += data['x'][inds[i]] + "," + data['y'][inds[i]] + "\\n";
        }
        var file = new Blob([out], {type: 'text/plain'});
        var elem = window.document.createElement('a');
        elem.href = window.URL.createObjectURL(file);
        elem.download = 'selected-data.txt';
        document.body.appendChild(elem);
        elem.click();
        document.body.removeChild(elem);
        """,
)

我已经搜索过其他人是否发生过此错误,但尚未发现任何内容。

【问题讨论】:

    标签: callback bokeh


    【解决方案1】:

    该示例使用的是 Bokeh 1.4.0,而您可能正在使用 Bokeh 2+。

    如果您将savebutton.callback = ... 替换为savebutton.js_on_click(...),它应该可以工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多