Skip to content

Instantly share code, notes, and snippets.

@nicain
Created June 14, 2017 23:24
Show Gist options
  • Save nicain/5a0236b688c166cb195d61e7735bcdcd to your computer and use it in GitHub Desktop.
Save nicain/5a0236b688c166cb195d61e7735bcdcd to your computer and use it in GitHub Desktop.
Create new tab for tabs
from bokeh.models.widgets import Panel, Tabs, Button
from bokeh.io import curdoc
from bokeh.plotting import figure
from bokeh.layouts import column, widgetbox
p1 = figure(plot_width=300, plot_height=300)
p1.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=20, color="navy", alpha=0.5)
tab1 = Panel(child=p1, title="circle")
p2 = figure(plot_width=300, plot_height=300)
p2.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], line_width=3, color="navy", alpha=0.5)
tab2 = Panel(child=p2, title="line")
tabs = Tabs(tabs=[ tab1, tab2 ])
button = Button(label='Add a tab')
def add_a_tab_button_callback():
p = figure(plot_width=300, plot_height=300)
p.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], line_width=3, color="navy", alpha=0.5)
t = Panel(child=p, title="line")
tabs.tabs.append(t)
print 'OK'
button.on_click(add_a_tab_button_callback)
layout = column([widgetbox(tabs, button)])
curdoc().add_root(layout)
@nicain
Copy link
Author

nicain commented Jun 14, 2017

Doesn't seem to work quite right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment