first many thanks for the 0.11 release
I have took the server application example from Running a Bokeh server — Bokeh 2.4.2 Documentation, it works perfectly well. The same with the notebook example. But when I adapt the server application example to run in notebook, the callback function doesn’t work anymore
first I have server running by
boken serve
then run the code in Jupyter notebook cell
import numpy as np
from bokeh.models import Button, TextInput
from bokeh.palettes import RdYlBu3
from bokeh.plotting import figure, curdoc, vplot
from bokeh.client import push_session
create a plot and style its properties
p = figure(x_range=(0, 100), y_range=(0, 100), toolbar_location=None)
p.border_fill_color = ‘black’
p.background_fill_color = ‘black’
p.outline_line_color = None
p.grid.grid_line_color = None
add a text renderer to out plot (no data yet)
r = p.text(x=, y=, text=, text_color=, text_font_size=“20pt”,
text_baseline=“middle”, text_align=“center”)
i = 0
ds = r.data_source
create a callback that will add a number in a random location
def callback(attr, old, new):
global i
ds.data[‘x’].append(np.random.random()*70 + 15)
ds.data[‘y’].append(np.random.random()*70 + 15)
ds.data[‘text_color’].append(RdYlBu3[i%3])
ds.data[‘text’].append(str(i))
ds.trigger(‘data’, ds.data, ds.data)
i = i + 1
add a button widget and configure with the call back
button = Button(label=“Press Me”)
button.on_click(callback)
text_input = TextInput(value=“default”, title=“Label:”)
text_input.on_change(“value”, callback)
put the button and plot in a layout and add to the document
curdoc().add_root(vplot(text_input, p))
session = push_session(curdoc())
session.show()
the callback function isn’t functioning