-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIB4Dui.py
More file actions
30 lines (18 loc) · 723 Bytes
/
Copy pathIB4Dui.py
File metadata and controls
30 lines (18 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from IPython.core.display import JSON, display, Javascript
import json
ui_json_decoder = json.JSONDecoder()
class SliderManager(object):
def __init__(self, panels):
self.panels = panels
def __call__(self):
bounds = dict(self.panels.bounds.limits())
js = "set_sliders(\'{0}\');".format(json.dumps(bounds))
display(Javascript(js))
class CallbackCenter(object):
def __init__(self, trigger_dict):
self.triggers = trigger_dict
def __call__(self, event_spec):
event_spec = ui_json_decoder.decode(event_spec)
item_id = event_spec.pop('item_id')
func = self.triggers[item_id]
func(**event_spec)