Python 3.x Bokeh布局:如何删除子项

Python 3.x Bokeh布局:如何删除子项,python-3.x,bokeh,children,Python 3.x,Bokeh,Children,我有一个Bokeh服务器代码,如下所示: listOfSubLayouts = main_layout.children plotToRemove = curdoc().get_model_by_name(self.plotid_long) logging.warning(plotToRemove.name) listOfSubLayouts.remove(plotToRemove) 删除行出现以下错误: error handling message Message 'PATCH-DOC' (

我有一个Bokeh服务器代码,如下所示:

listOfSubLayouts = main_layout.children
plotToRemove = curdoc().get_model_by_name(self.plotid_long)
logging.warning(plotToRemove.name)
listOfSubLayouts.remove(plotToRemove)
删除行出现以下错误:

error handling message Message 'PATCH-DOC' (revision 1): ValueError('list.remove(x): x not in list',)
有人能解释一下这里可能出了什么问题吗?这是我在这里找到的解决方案:


可能不在Bokeh服务器环境中工作?

检查此示例是否对您有所帮助,您可以将子项视为一个列表。检查我在哪里解释,并询问可能的替代方案

来自bokeh.models导入按钮,ColumnDataSource
从bokeh.layouts导入列,布局
来自bokeh.doc,图
图(
title='第三个数字',
宽度=400,
高度=400,
x_范围=[-5,10],
y_范围=(0,5),
工具=“平移、滚轮缩放、放大、缩小、选择框、选择套索、轻触、重置”,
x_轴标签='x轴',
y轴标签='y轴',
)
x=[1,2,3,4]
y=[4,3,2,1]
source=ColumnDataSource(数据=dict(x=x,y=y))
无花果圈(
x='x',
y='y',
来源=来源,
半径=0.5,
填充α=0.6,
填充颜色为绿色,
线条颜色='黑色',
)
def添加按钮():
打印(“添加图形”)
布局.children.append(图)
def卸下按钮():
打印(“删除图形”)
layout.children.pop()
按钮=按钮(label=“单击以添加图形”,button\u type=“success”)
按钮。单击(添加按钮)
button\u rmv=button(label=“单击以删除图形”,button\u type=“成功”)
按钮。点击(移除按钮)
布局=布局([[按钮,按钮]])
curdoc().添加根目录(布局)

嗨,也许那些帖子能帮上忙