Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Supporting Style class in dictionary based questions. #250

Open
e0lithic opened this issue Sep 2, 2022 · 0 comments
Open
Labels
Enhancement New feature or request

Comments

@e0lithic
Copy link

e0lithic commented Sep 2, 2022

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.

@e0lithic e0lithic added the Enhancement New feature or request label Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant