From 9d181f9f8c4cd465c2f08ffd5072cbfcdbd2ba44 Mon Sep 17 00:00:00 2001 From: Jack Foltz Date: Sat, 8 Dec 2018 23:46:22 -0500 Subject: [PATCH] Add enable/disable all hotkey --- lib/menu.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/menu.py b/lib/menu.py index 6365f03..860d0dc 100755 --- a/lib/menu.py +++ b/lib/menu.py @@ -109,12 +109,28 @@ class ChecklistMenu(Menu): text_mode = curses.A_REVERSE if index == self.position else curses.A_NORMAL self.window.addstr(index + 3, 1, text, text_mode) + def all(self, val): + for i in range(0, len(self.states)): + self.states[i] = val + + for item in self.items: + fn = item[1] + if isinstance(fn, LambdaType): + fn(val) + + def input(self, key): super().input(key) if key == ord('\t'): self.expand(self.position) + if key == ord('e'): + self.all(True) + + if key == ord('d'): + self.all(False) + def expand(self, index): if len(self.items[index]) >= 3: self.items[index][2]()