summaryrefslogtreecommitdiff
path: root/alot/widgets
diff options
context:
space:
mode:
authorMartin Schaaf <mschaaf@datameer.com>2017-11-01 20:15:34 +0100
committerMartin Schaaf <mschaaf@datameer.com>2017-11-01 20:15:34 +0100
commitadf67b9c7ba6547b660be1b3531ec05b86bc169a (patch)
tree4fe258dbd0fa81a67773ee79697433a572c36142 /alot/widgets
parent969dd7b1b71b6882cecd95427b60c3f61176d578 (diff)
* Extend ChoiceWidget to differentiate between a list of choices
and a list of return objects for choices.
Diffstat (limited to 'alot/widgets')
-rw-r--r--alot/widgets/globals.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/alot/widgets/globals.py b/alot/widgets/globals.py
index 3aea7622..38b16544 100644
--- a/alot/widgets/globals.py
+++ b/alot/widgets/globals.py
@@ -44,9 +44,10 @@ class AttachmentWidget(urwid.WidgetWrap):
class ChoiceWidget(urwid.Text):
- def __init__(self, choices, callback, cancel=None, select=None,
- separator=' '):
+ def __init__(self, choices, callback, choices_to_return=None,
+ cancel=None, select=None, separator=' '):
self.choices = choices
+ self.choices_to_return = choices_to_return or {}
self.callback = callback
self.cancel = cancel
self.select = select
@@ -69,6 +70,8 @@ class ChoiceWidget(urwid.Text):
self.callback(self.select)
elif key == 'esc' and self.cancel is not None:
self.callback(self.cancel)
+ elif key in self.choices_to_return:
+ self.callback(self.choices_to_return[key])
elif key in self.choices:
self.callback(self.choices[key])
else: