summaryrefslogtreecommitdiff
path: root/alot/ui.py
diff options
context:
space:
mode:
authorDylan Baker <baker.dylan.c@gmail.com>2018-02-08 11:06:06 -0800
committerGitHub <noreply@github.com>2018-02-08 11:06:06 -0800
commit7091048adf3e4455fb2e3adfe27ce1e10165a5e3 (patch)
tree7dce25542adaed372aed78122b7ee29a049bb53a /alot/ui.py
parent7a37daee30c271e2aca7546bee910d419e4c2998 (diff)
parentd16bc108a17786e0bacc174106dfce779361e548 (diff)
Merge pull request #1172 from Dica-Developer/patch-4
Fix for issue 1164 - Cannot select key for encryption by number keys
Diffstat (limited to 'alot/ui.py')
-rw-r--r--alot/ui.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/alot/ui.py b/alot/ui.py
index f82feda4..68a21f6d 100644
--- a/alot/ui.py
+++ b/alot/ui.py
@@ -484,7 +484,7 @@ class UI(object):
self.update()
def choice(self, message, choices=None, select=None, cancel=None,
- msg_position='above'):
+ msg_position='above', choices_to_return=None):
"""
prompt user to make a choice.
@@ -492,6 +492,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
@@ -504,6 +507,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']
@@ -520,8 +524,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':