Created
June 14, 2017 23:54
-
-
Save nicain/fccc9a83ac0b382ba093b0e4548fe904 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | |
tabs = Tabs(tabs=[tab1]) | |
button = Button(label='Add a tab') | |
button = Button(label='Add a tab') | |
wb = widgetbox(tabs, button) | |
layout = column([wb]) | |
def add_a_tab_button_callback(): | |
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) | |
new_tab = Panel(child=p2, title="line") | |
cur_old_tabs = wb.children[0] | |
new_tabs = Tabs(tabs=cur_old_tabs.tabs + [new_tab]) | |
wb.children = [new_tabs, button] | |
button.on_click(add_a_tab_button_callback) | |
curdoc().add_root(layout) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment