Created
March 30, 2018 20:54
-
-
Save mattpap/70544bd158ecec52f69a014a6aeb05fd to your computer and use it in GitHub Desktop.
Cycle bokeh's tabs with CustomJS
This file contains 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.io import save | |
from bokeh.plotting import figure | |
from bokeh.layouts import column | |
from bokeh.models import CustomJS | |
from bokeh.models.widgets import Button, Tabs, Panel | |
def make_tab(color): | |
p = figure() | |
p.scatter([0], [0], color=color, radius=1) | |
return Panel(title="Tab: %s" % color.capitalize(), child=p) | |
red = make_tab("red") | |
green = make_tab("green") | |
blue = make_tab("blue") | |
tabs = Tabs(tabs=[red, green, blue]) | |
next_tab = CustomJS(args=dict(tabs=tabs), code=""" | |
tabs.active = (tabs.active + 1) % tabs.tabs.length | |
""") | |
button = Button(label="Next tab", callback=next_tab) | |
save(column(button, tabs)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment