diff --git a/actor.py b/actor.py index 82c16f0..2d197f6 100644 --- a/actor.py +++ b/actor.py @@ -60,6 +60,16 @@ class Actor: self.src, plt, self.cache, self._update = decide_src_plt_cache_update(pvname) self.plt = Frame(plt) + self.plt.cfg_ti_cache_size.value = str(self.cache.size) + self.plt.cfg_ti_cache_size.on_change("value", self.do_update_cache_size) + + + def do_update_cache_size(self, attr, old, new): + print(f"CB Update cache size: attribute \"{attr}\" changed from \"{old}\" to \"{new}\"") + self.cache.set_size(int(new)) + self.plt.cfg_ti_cache_size.value = str(self.cache.size) + + def update(self): self._update(self.plt, self.cache) diff --git a/frame.py b/frame.py index be2578a..fc229ba 100644 --- a/frame.py +++ b/frame.py @@ -1,5 +1,5 @@ from bokeh.layouts import column, row -from bokeh.models import Button, Div, Spacer +from bokeh.models import Button, Div, Spacer, TextInput CROSS = "🗙" @@ -28,11 +28,8 @@ class Frame: self.cfg_dialog = cfg_dialog = column() cfg_dialog.visible = False - #TODO: the following is just a dummy - types = ("light", "default", "primary", "success", "warning", "danger") - for t in types: - btn = Button(label=t, button_type=t, height=35) #TODO: why does this need height to be set? (otherwise buttons are only properly sized on NEXT click!) - cfg_dialog.children.append(btn) + self.cfg_ti_cache_size = cfg_ti_cache_size = TextInput(value="", title="Cache size:") + cfg_dialog.children.append(cfg_ti_cache_size) self.btn_cfg.on_click(self.do_click_cfg) @@ -49,6 +46,7 @@ class Frame: self.btn_close.on_click(*args, **kwargs) def do_click_cfg(self): + toggle_button_state(self.btn_close) # do not close plot from cfg dialog toggle_button_type(self.btn_cfg, "default", "warning") self.inner.visible = False switch_visibility(self.plt.fig, self.cfg_dialog) @@ -56,6 +54,9 @@ class Frame: +def toggle_button_state(btn): + btn.disabled = not btn.disabled + def toggle_button_type(btn, type1, type2): btn.button_type = type2 if btn.button_type == type1 else type1