separate root layout and plot-container layout

This commit is contained in:
2021-05-28 14:36:57 +02:00
parent e8789e312f
commit 4cb272d268

View File

@ -16,7 +16,8 @@ class Director:
self.ti_add_pv = ti_add_pv = TextInput(value="", title="Add PV:") self.ti_add_pv = ti_add_pv = TextInput(value="", title="Add PV:")
ti_add_pv.on_change("value", self.on_add_pv) ti_add_pv.on_change("value", self.on_add_pv)
self.layout = layout = column(ti_add_pv) self.plot_container = plot_container = column()
layout = column(ti_add_pv, plot_container)
doc.add_root(layout) doc.add_root(layout)
@ -60,8 +61,8 @@ class Director:
def add_plot(self, a): def add_plot(self, a):
print("Add plot:", a) print("Add plot:", a)
fig = a.plt.fig fig = a.plt.fig
# self.layout.children.append(fig) # self.plot_container.children.append(fig)
self.layout.children.insert(1, fig) # 1 to skip TextInput self.plot_container.children.insert(0, fig)
assert a.cb is None #TODO assert a.cb is None #TODO
a.cb = self.doc.add_periodic_callback(a.update, 1000) a.cb = self.doc.add_periodic_callback(a.update, 1000)
@ -69,7 +70,7 @@ class Director:
def remove_plot(self, a): def remove_plot(self, a):
print("Remove plot:", a) print("Remove plot:", a)
fig = a.plt.fig fig = a.plt.fig
self.layout.children.remove(fig) self.plot_container.children.remove(fig)
assert a.cb is not None #TODO assert a.cb is not None #TODO
self.doc.remove_periodic_callback(a.cb) self.doc.remove_periodic_callback(a.cb)