summaryrefslogtreecommitdiff
path: root/alot/ui.py
diff options
context:
space:
mode:
authorMartin Schaaf <mschaaf@datameer.com>2017-11-01 20:18:54 +0100
committerMartin Schaaf <mschaaf@datameer.com>2017-11-01 20:18:54 +0100
commit6243ceef045e888a158e0d97b6d4e48108603c64 (patch)
treec363ca61f13054e1daa4b9b9f5396a46b2357479 /alot/ui.py
parentadf67b9c7ba6547b660be1b3531ec05b86bc169a (diff)
* Extend choice to diffefrentiate between a list of choices
and a list of return objects for choices.
Diffstat (limited to 'alot/ui.py')
-rw-r--r--alot/ui.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/alot/ui.py b/alot/ui.py
index c97f2fc1..9dd84425 100644
--- a/alot/ui.py
+++ b/alot/ui.py
@@ -481,8 +481,8 @@ class UI(object):
self._notificationbar = None
self.update()
- def choice(self, message, choices=None, select=None, cancel=None,
- msg_position='above'):
+ def choice(self, message, choices=None, choices_to_return=None,
+ select=None, cancel=None, msg_position='above'):
"""
prompt user to make a choice.
@@ -490,6 +490,9 @@ class UI(object):
:type message: unicode
:param choices: dict of possible choices
:type choices: dict: keymap->choice (both str)
+ :param choices_to_return: dict of possible choices to return for the
+ choices of the choices of paramter
+ :type choices: dict: keymap->choice key is str and value is any obj)
:param select: choice to return if enter/return is hit. Ignored if set
to `None`.
:type select: str
@@ -502,6 +505,7 @@ class UI(object):
:rtype: :class:`twisted.defer.Deferred`
"""
choices = choices or {'y': 'yes', 'n': 'no'}
+ choices_to_return = choices_to_return or {}
assert select is None or select in choices.itervalues()
assert cancel is None or cancel in choices.itervalues()
assert msg_position in ['left', 'above']
@@ -518,8 +522,10 @@ class UI(object):
# set up widgets
msgpart = urwid.Text(message)
- choicespart = ChoiceWidget(choices, callback=select_or_cancel,
- select=select, cancel=cancel)
+ choicespart = ChoiceWidget(choices,
+ choices_to_return=choices_to_return,
+ callback=select_or_cancel, select=select,
+ cancel=cancel)
# build widget
if msg_position == 'left':