Синтаксис .get(...)
был удален очень давно.В любой довольно свежей версии Bokeh просто зайдите, например, .value
напрямую.Кроме того, для определения text_input
внутри обратного вызова необходимо передать его в args
.Вот обновленная версия вашего кода:
from bokeh.io import show
from bokeh.layouts import column, row
from bokeh.models import CustomJS, TextInput
from bokeh.plotting import figure
fig = figure(title='title')
fig.line(x=[1,2,3], y=[1,2,3])
text_input = TextInput(title="Add graph title", value='')
text_input.js_on_change('value', CustomJS(
args={'title': fig.title, 'text_input': text_input},
code="title.text = text_input.value"
))
widgets_layout = column(text_input)
figures_layout = row(fig)
show(row(widgets_layout, fig))
ОДНАКО, с Bokeh> = 1.1, вы можете просто использовать js_link
и избегать создания всего CustomJS
:
text_input = TextInput(title="Add graph title", value='')
text_input.js_link('value', fig.title, 'text')