Python text.on_更改对Bokeh TextInput没有响应

Python text.on_更改对Bokeh TextInput没有响应,python,plot,onchange,bokeh,textinput,Python,Plot,Onchange,Bokeh,Textinput,我是使用Python的bokeh绘图工具和小部件的初学者。在下面的代码中,我试图将图形的标题更改为TextInput框的值。但是,当输入文本并取消聚焦时,该框出现,但没有任何变化。什么可能导致此问题?我可以做些什么来修复它 p=figure( height=400, x_axis_type='datetime', title=(company+' ('+tickerstring+') ') ) thedates = np.array(stockdates, dtype

我是使用Python的bokeh绘图工具和小部件的初学者。在下面的代码中,我试图将图形的标题更改为TextInput框的值。但是,当输入文本并取消聚焦时,该框出现,但没有任何变化。什么可能导致此问题?我可以做些什么来修复它

p=figure(
    height=400,
    x_axis_type='datetime',
    title=(company+' ('+tickerstring+') ')
)


thedates = np.array(stockdates, dtype=np.datetime64)
source = ColumnDataSource(data=dict(
    x=thedates,
    y=stockcloseprices
))


p.line('x', 'y', source=source)

p.grid.grid_line_color="white"
p.xaxis.axis_label = 'Date'
p.yaxis.axis_label = 'Price'
p.add_tools(HoverTool(
    tooltips=[
        ("Date", "@x{%F}"),
        ('Close',"@y")
    ],
    formatters={
        'x':'datetime', # use 'datetime' formatter for 'date' field
    },
    mode='vline'
))


def update_title(attrname, old, new):
    p.title = text.value

div = Div(text='<br><b> Key Points </b><br><br>'+percentagechange+'<br><br>'+performance,
width=200, height=100)


text = TextInput(value='Name', title="Enter Ticker Here:")
text.on_change('value', update_title)

grid = gridplot([p, div, text], ncols=2, plot_width=570, plot_height=400)
show(grid)
p=图(
高度=400,
x_轴类型='datetime',
title=(公司+”(“+tickerstring+”))
)
thedates=np.array(stockdates,dtype=np.datetime64)
source=ColumnDataSource(数据=dict(
x=日期,
y=股票收盘价
))
p、 行('x','y',源=源)
p、 grid.grid\u line\u color=“白色”
p、 xaxis.axis_标签='Date'
p、 yaxis.axis_标签='Price'
p、 添加工具(鼠标悬停工具(
工具提示=[
(“日期”,“@x{%F}”),
(‘Close’,“@y”)
],
格式化程序={
'x':'datetime',#对'date'字段使用'datetime'格式化程序
},
mode='vline'
))
def更新标题(属性名称、旧名称、新名称):
p、 title=text.value
div=div(text='
关键点

'+百分比变化+'

'+绩效, 宽度=200,高度=100) text=TextInput(value='Name',title=“在此处输入代码:”) 文本。更改时(“值”,更新标题) 网格=网格图([p,div,text],ncols=2,绘图宽度=570,绘图高度=400) 显示(网格)
通过使用
显示(网格)
您正在创建一个独立的HTML文档作为输出。这不可能运行真正的python回调,因为浏览器无法运行python代码。运行真正的回调需要连接到持久的Python进程。那是Bokeh服务器。只有在bokeh服务器应用程序中才可能使用真正的python回调(即,在更改时使用
)(这是bokeh服务器的目的,是运行真正的python回调)。请参阅:

也可以将Bokeh服务器应用程序嵌入Juyter笔记本电脑中,例如,请参见此处: