#!/usr/bin/env python import numpy as np from bokeh.layouts import row, column#, layout from bokeh.models import Button, ColumnDataSource from bokeh.models import Spacer from bokeh.models.widgets import Div, Panel, Tabs from bokeh.plotting import curdoc from bokeh.plotting import figure def add_button(): print("adding") btn = Button(label="🗙", button_type="light", width=35) lbl = Div(text="A test plot", align="center", style={"font-size": "150%"}) data = { "x": [0, 1, 2], "y": np.random.random((3,)) } source = ColumnDataSource(data=data) fig = figure() fig.step(x="x", y="y", source=source, mode="after") fig.circle(x="x", y="y", source=source) combo = column(row(btn, lbl), fig, Spacer(height=35)) btn.on_click(lambda: remove_button(combo)) layout.children.append(combo) def remove_button(which): print("removing", which) layout.children.remove(which) button = Button(label="Click to add", button_type="success") #button0 = Button(label="Click to add", button_type="default") #button1 = Button(label="Click to add", button_type="primary") #button2 = Button(label="Click to add", button_type="success") #button3 = Button(label="Click to add", button_type="warning") #button4 = Button(label="Click to add", button_type="danger") #button5 = Button(label="Click to add", button_type="light") button.on_click(add_button) layout = column(button)#, button0, button1, button2, button3, button4, button5) curdoc().add_root(layout)