admin管理员组文章数量:1400837
I have a bokeh server application (3.7.0). When the application is started one tab is shown and when the execute button is pressed another tab is added. It works as long as the second tab does not contain figures. How can I solve this?
from bokeh.io import curdoc
from bokeh.layouts import layout
from bokeh.models.widgets import Div, Button
from bokeh.models import Tabs, TabPanel
from bokeh.plotting import figure
def tab1():
w_1 = Div(text="<b>T1</b>",
styles={'font_family': 'arial', 'text_align': 'center', 'font-size': '20px', 'color': 'blue'}, width=200, height=100)
p1 = figure(width=300, height=300)
p1.scatter([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=20, color="navy", alpha=0.5)
w_execute = Button(label='Execute', name='Execute')
l1 = layout([[w_1],
[p1],
[w_execute]])
t1 = TabPanel(child=l1,title="T1")
tabs = Tabs(tabs=[t1])
def func_run(new):
add_t2(t1)
w_execute.on_click(func_run)
curdoc().add_root(tabs)
def add_t2(t1):
curdoc().clear()
t2 = tab2()
tabs = Tabs(tabs = [t1, t2])
curdoc().add_root(tabs)
def tab2():
w_2 = Div(text="<b>T2</b>",
styles={'font_family': 'arial', 'text_align': 'center', 'font-size': '20px', 'color': 'blue'}, width=200, height=100)
p2 = figure(width=300, height=300)
p2.scatter([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=20, color="navy", alpha=0.5)
# l2 = layout([[w_2],
# [p2]]) # Does not work
l2 = layout([[w_2]]) # Works
t2 = TabPanel(child=l2,title="T2")
return t2
tab1()
本文标签: pythonDynamically add tabs with figures in bokehStack Overflow
版权声明:本文标题:python - Dynamically add tabs with figures in bokeh - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744203299a2595068.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论