将散景控件小部件置于选项卡小部件上方

时间:2019-01-13 06:25:23

标签: python layout bokeh

这个问题是关于在Bokeh的选项卡小部件上方放置控件小部件的。

我有工作代码可以生成“选项卡”布局,其中每个选项卡表都在图形上方设置了控件:

%timeit csv_reader_4(StringIO(x)) # 3.51 s per loop

并且对象 tabs 已成功添加到文档的根目录。一切正常。

我收到的建议是,由于我的控件都是相同的,并且我希望它们保持同步,所以我应该只使用一组控件并将它们放在选项卡上方。

所以我尝试了这个:

def make_plots(self):
    p1 = self.make_plot(...
    p2 = self.make_plot(...
    p3 = self.make_plot(...
    p4 = self.make_plot(...

    c1 = MakeControls(self)
    c2 = MakeControls(self)
    c3 = MakeControls(self)
    c4 = MakeControls(self)

    # put these in a tuple so they can be synchronized whenever one changes
    self.plot_set    = (p1, p2, p3, p4)
    self.control_set = (c1, c2, c3, c4)

    p1_ = Column(c1.controls, p1)
    p2_ = Column(c2.controls, p2)
    p3_ = Column(c3.controls, p3)
    p4_ = Column(c4.controls, p4)
    tab1 = Panel(child = p1_, title = self.type_labels[1])
    tab2 = Panel(child = p2_, title = self.type_labels[2])
    tab3 = Panel(child = p3_, title = self.type_labels[3])
    tab4 = Panel(child = p4_, title = self.type_labels[4])
    tabs = Tabs(tabs=[tab1,tab2,tab3,tab4])

    return tabs

使用Column以这种方式出现错误。当我在单个图形上方堆叠一个控件集时,此方法有效,但当我尝试在选项卡集上方堆叠单个控件时,此方法不起作用。

我看到的唯一有意义的消息是:

  

ValueError:预期为List(Instance(LayoutDOM))的元素,并使用无效项获得了seq

正确的方法是什么?

0 个答案:

没有答案