-
Notifications
You must be signed in to change notification settings - Fork 0
/
everything_bagel_common.py
43 lines (38 loc) · 1.61 KB
/
everything_bagel_common.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
class ToggleExclusive:
def __init__(self, attr, active_val, inactive_val, curr_active_elem):
'''
get_updater: a functor that returns the update function
'''
# self.gelems = gelems
self.attr = attr
self.curr_active_elem = curr_active_elem
self.curr_active_elem = None
self.active_val = active_val
self.inactive_val = inactive_val
def set_active(self, window, event):
window.Element(event).Update(**{self.attr: self.active_val})
if self.curr_active_elem is not None:
window.Element(self.curr_active_elem).Update(
**{self.attr: self.inactive_val})
print("setting active: ", event)
self.curr_active_elem = event
class ToggleExclusiveOther:
def __init__(self, attr, active_val, inactive_val, curr_active_elem):
'''
get_updater: a functor that returns the update function
'''
# self.gelems = gelems
self.attr = attr
self.curr_active_elem = curr_active_elem
self.curr_active_elem = None
self.active_val = active_val
self.inactive_val = inactive_val
def set_active(self, window, event):
oevent = get_key_from_label("_".join(event.split("_")[1:]))
#print("toggle called for event=", "_".join(event.split("_")[1:]))
# print(window.Element(oevent))
window.Element(oevent).Update(**{self.attr: self.active_val})
if self.curr_active_elem is not None:
window.Element(self.curr_active_elem).Update(
**{self.attr: self.inactive_val})
self.curr_active_elem = oevent