With the bokeh module in python i want to add a server callback when someone selects a different panel. Something like this (unfortunatly it is not working):
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)
Edit: This is in bokeh 0.13.0
You should try (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)