questionary
questionary copied to clipboard
[Feature Request] Supporting Style class in dictionary based questions.
Describe the problem
Currently, the "style" attribute in the dictionary based questions only supports basic text based styling attribute but doesn't allow passing the style class instance.
Describe the solution
custom_style_fancy = Style(
[
("separator", "fg:#cc5454"),
("qmark", "fg:#673ab7 bold"),
("question", ""),
("selected", "fg:#cc5454"),
("pointer", "fg:#673ab7 bold"),
("highlighted", "fg:#673ab7 bold"),
("answer", "fg:#f44336 bold"),
("text", "fg:#FBE9E7"),
("disabled", "fg:#858585 italic"),
]
)
def ask_dictstyle(**kwargs):
questions = [
{
# just print a message, don't ask a question
# does not require a name (but if provided, is ignored) and does not return a value
"type": "print",
"name": "intro",
"message": "This example demonstrates advanced features! 🦄",
"style": custom_style_fancy
}
]
return prompt(questions, **kwargs)
if __name__ == "__main__":
print(ask_dictstyle())
Alternatives considered
Although similar results can be obtained by using the pythonic style, but it eludes the simplicity of the dictionary based question generation.