Files
kabuki/prototypes/dyn1.py

39 lines
1004 B
Python

#!/usr/bin/env python
from bokeh.layouts import column#, layout
from bokeh.models import Button, ColumnDataSource
from bokeh.models.widgets import Div, Panel, Tabs
from bokeh.plotting import curdoc
from bokeh.plotting import figure
def add_button():
print("adding")
data = {
"x": [0, 1, 2],
"y": [2, 0, 1]
}
source = ColumnDataSource(data=data)
fig = figure()
fig.step(x="x", y="y", source=source, mode="after")
fig.circle(x="x", y="y", source=source)
pan = Panel(child=fig, title="test", closable=True)
tab = [pan]
size = 25
height, width = fig.height, fig.width
btn = Button(label="X", button_type="danger", margin=(-height+size, 0, 0, width-size), width=0, height=0, width_policy="fixed", height_policy="fixed")
layout.children.append(Tabs(tabs=tab))
layout.children.append(btn)
button = Button(label="Click to add", button_type="success")
button.on_click(add_button)
layout = column(button)
curdoc().add_root(layout)