added "set cache size" to cfg dialog; disable close button when in cfg dialog

This commit is contained in:
2021-05-31 21:46:54 +02:00
parent 00d31cb084
commit 487cc374ba
2 changed files with 17 additions and 6 deletions
+10
View File
@@ -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)
+7 -6
View File
@@ -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