Skip to main content
 首页 » 编程设计

python之如何在 jupyter_notebook 中显示 curdoc() 仪表板

2024年11月24日10zfyouxi

我在 jupter_notebook 中工作,并创建了两个仪表板。我使用 curdoc() 将它们放在一个带有两个选项卡的文档中,如下所示,然后尝试在 jupyter_notebook 中作为应用程序输出,但出现错误。如何解决?非常感谢。

def group1_tab(df): 
 *********** 
 controls=WidgetBox(******) 
 layout=row(controls,p) 
 tab=Panel(child=layout,title='group1') 
 return tab 
 
def group2_tab(df): 
  *********** 
   layout=row(controls,p) 
   tab=Panel(child=layout,title='group2') 
   return tab 
 
tab1 = group1_tab(df) 
tab2 = group2_tab(df) 
 
# Put all the tabs into one application 
tabs = Tabs(tabs = [tab1, tab2]) 
 
# Put the tabs in the current document for display 
curdoc().add_root(tabs) 
 
handler=FunctionHandler(curdoc()) 
app=Application(handler) 
 
show(app) 
 
----> 1 handler=FunctionHandler(curdoc()) 

更新---- 终于得到了一个适合我的作品。

def make_doc(doc): 
    tab1=*** 
    tab2=*** 
    tabs=Tabs(tabs=[tab1,tab2]) 
    doc.add_root(tabs) 
show(make_doc) 

请您参考如下方法:

我认为应该是:

handler=FunctionHandler(curdoc) 

代替:

handler=FunctionHandler(curdoc())