Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions questionary/prompts/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from typing import Union

from prompt_toolkit.application import Application
from prompt_toolkit.formatted_text import FormattedText as PTFormattedText
from prompt_toolkit.key_binding import KeyBindings
from prompt_toolkit.keys import Keys
from prompt_toolkit.styles import Style
Expand All @@ -24,7 +25,7 @@


def select(
message: str,
message: Union[str, Dict[str, Any]],
choices: Sequence[Union[str, Choice, Dict[str, Any]]],
default: Optional[Union[str, Choice, Dict[str, Any]]] = None,
qmark: str = DEFAULT_QUESTION_PREFIX,
Expand Down Expand Up @@ -176,7 +177,13 @@ def select(

def get_prompt_tokens():
# noinspection PyListCreation
tokens = [("class:qmark", qmark), ("class:question", " {} ".format(message))]
tokens = [("class:qmark", qmark)]
if isinstance(message, (list, PTFormattedText)):
tokens += message
elif hasattr(message, "__pt_formatted_text__"):
tokens += list(message.__pt_formatted_text__())
else:
tokens.append(("class:question", " {} ".format(message)))

if ic.is_answered:
if isinstance(ic.get_pointed_at().title, list):
Expand Down