Bokeh python 面板/选项卡选择回调
Bokeh python callback on panel / tab selection
使用 python 中的散景模块,我想在有人选择不同的面板时添加服务器回调。像这样的东西(不幸的是它不起作用):
from bokeh.layouts import widgetbox
from bokeh.models.widgets import Div, Tabs, Panel
from bokeh.plotting import curdoc
label1 = Div(text='Tab 1')
label2 = Div(text='Tab 2')
panel1 = Panel(child=widgetbox(label1), title='Tab 1')
panel2 = Panel(child=widgetbox(label2), title='Tab 2')
tabs = Tabs(tabs=[panel1, panel2])
def panelActive():
print("the active panel is "+str(tabs.active))
tabs.callback=panelActive()
curdoc().add_root(tabs)
编辑:这是散景 0.13.0
你应该试试 (Bokeh v1.1.0):
from bokeh.layouts import widgetbox
from bokeh.models import Div, Tabs, Panel
from bokeh.plotting import curdoc
label1 = Div(text = 'Tab 1')
label2 = Div(text = 'Tab 2')
panel1 = Panel(child = widgetbox(label1), title = 'Tab 1')
panel2 = Panel(child = widgetbox(label2), title = 'Tab 2')
tabs = Tabs(tabs = [panel1, panel2])
def panelActive(attr, old, new):
print("the active panel is " + str(tabs.active))
tabs.on_change('active', panelActive)
curdoc().add_root(tabs)
使用 python 中的散景模块,我想在有人选择不同的面板时添加服务器回调。像这样的东西(不幸的是它不起作用):
from bokeh.layouts import widgetbox
from bokeh.models.widgets import Div, Tabs, Panel
from bokeh.plotting import curdoc
label1 = Div(text='Tab 1')
label2 = Div(text='Tab 2')
panel1 = Panel(child=widgetbox(label1), title='Tab 1')
panel2 = Panel(child=widgetbox(label2), title='Tab 2')
tabs = Tabs(tabs=[panel1, panel2])
def panelActive():
print("the active panel is "+str(tabs.active))
tabs.callback=panelActive()
curdoc().add_root(tabs)
编辑:这是散景 0.13.0
你应该试试 (Bokeh v1.1.0):
from bokeh.layouts import widgetbox
from bokeh.models import Div, Tabs, Panel
from bokeh.plotting import curdoc
label1 = Div(text = 'Tab 1')
label2 = Div(text = 'Tab 2')
panel1 = Panel(child = widgetbox(label1), title = 'Tab 1')
panel2 = Panel(child = widgetbox(label2), title = 'Tab 2')
tabs = Tabs(tabs = [panel1, panel2])
def panelActive(attr, old, new):
print("the active panel is " + str(tabs.active))
tabs.on_change('active', panelActive)
curdoc().add_root(tabs)