refactored on_change logic

This commit is contained in:
2021-06-15 16:43:57 +02:00
parent 45bb10f41f
commit 8a909e4664
3 changed files with 11 additions and 8 deletions

View File

@ -1,6 +1,6 @@
from .frame import Frame
from .logic import decide_src_plt_cfg
from .utils import cb
from .utils import bind
from .cfgdlgs import ConfigDialog1D, ConfigDialog2D #TODO
@ -17,7 +17,7 @@ class Actor:
self.cache = cache = src.cache.get_view()
cfg.sp_cache_size.value = cache.size
cfg.sp_cache_size.on_change("value", cb(self.do_update_cache_size))
bind(cfg.sp_cache_size, self.do_update_cache_size)
if isinstance(cfg, ConfigDialog1D): #TODO
cfg.cb_curves_latest.active = plt.line_latest.visible
@ -36,12 +36,12 @@ class Actor:
cfg.sp_binning.value = plt.binning
cfg.sel_cmap_palette.on_change("value", cb(plt.change_cmap_palette))
bind(cfg.sel_cmap_palette, plt.change_cmap_palette)
cfg.cb_cmap_reverse.on_click(plt.change_cmap_reverse)
cfg.sp_vmin.on_change("value", cb(plt.change_vmin))
cfg.sp_vmax.on_change("value", cb(plt.change_vmax))
cfg.sp_binning.on_change("value", cb(plt.change_binning))
bind(cfg.sp_vmin, plt.change_vmin)
bind(cfg.sp_vmax, plt.change_vmax)
bind(cfg.sp_binning, plt.change_binning)
def delete(self):

View File

@ -6,7 +6,7 @@ from bokeh.plotting import curdoc
from .actor import Actor
from .buki import Column, Row
from .utils import cb
from .utils import bind
class Director:
@ -16,7 +16,7 @@ class Director:
doc.title = choice("👺👹") + " kabuki"
self.sp_add_pvs = sp_add_pvs = TextInput(value="", title="Add PV:")
sp_add_pvs.on_change("value", cb(self.do_add_pvs))
bind(sp_add_pvs, self.do_add_pvs)
self.plot_container = plot_container = Column()
root_container = column(sp_add_pvs, Spacer(height=15), plot_container.layout)

View File

@ -1,4 +1,7 @@
def bind(obj, handler):
obj.on_change("value", cb(handler))
def cb(handler):
def wrapper(_attr, _old, new):
handler(new)