How to use the questionary.question.Question function in questionary

To help you get started, we’ve selected a few questionary examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tmbo / questionary / questionary / prompts / select.py View on Github external
def move_cursor_up(event):
            ic.select_previous()
            while not ic.is_selection_valid():
                ic.select_previous()

    @bindings.add(Keys.ControlM, eager=True)
    def set_answer(event):
        ic.is_answered = True
        event.app.exit(result=ic.get_pointed_at().value)

    @bindings.add(Keys.Any)
    def other(event):
        """Disallow inserting other text. """
        pass

    return Question(
        Application(layout=layout, key_bindings=bindings, style=merged_style, **kwargs)
    )
github layday / instawow / instawow / prompts.py View on Github external
webbrowser.open(pkg.url)

    @bindings.add('s', eager=True)
    def skip(event: Any):
        ic.pointed_at = -1
        ic.is_answered = True
        event.app.exit(result=ic.get_pointed_at().value)

    @bindings.add(Keys.Any)
    def other(event: Any):
        # Disallow inserting other text
        pass

    layout = create_inquirer_layout(ic, get_prompt_tokens, **prompt_kwargs)
    app = Application(layout=layout, key_bindings=bindings, style=qstyle, **prompt_kwargs)
    return Question(app)
github tmbo / questionary / questionary / prompts / checkbox.py View on Github external
def move_cursor_up(event):
        ic.select_previous()
        while not ic.is_selection_valid():
            ic.select_previous()

    @bindings.add(Keys.ControlM, eager=True)
    def set_answer(event):
        ic.is_answered = True
        event.app.exit(result=[c.value for c in ic.get_selected_values()])

    @bindings.add(Keys.Any)
    def other(event):
        """Disallow inserting other text. """
        pass

    return Question(
        Application(layout=layout, key_bindings=bindings, style=merged_style, **kwargs)
    )
github tmbo / questionary / questionary / prompts / confirm.py View on Github external
    @bindings.add("Y")
    def key_y(event):
        status["answer"] = True
        event.app.exit(result=True)

    @bindings.add(Keys.ControlM, eager=True)
    def set_answer(event):
        status["answer"] = default
        event.app.exit(result=default)

    @bindings.add(Keys.Any)
    def other(event):
        """Disallow inserting other text."""
        pass

    return Question(
        PromptSession(
            get_prompt_tokens, key_bindings=bindings, style=merged_style, **kwargs
        ).app
github tmbo / questionary / questionary / prompts / autocomplete.py View on Github external
ignore_case=ignore_case,
            meta_information=get_meta_style(meta_information),
            match_middle=match_middle,
        )

    p = PromptSession(
        get_prompt_tokens,
        style=merged_style,
        completer=completer,
        validator=validator,
        complete_style=complete_style,
        **kwargs,
    )
    p.default_buffer.reset(Document(default))

    return Question(p.app)
github tmbo / questionary / questionary / prompts / text.py View on Github external
Question: Question instance, ready to be prompted (using `.ask()`).
    """

    merged_style = merge_styles([DEFAULT_STYLE, style])

    validator = build_validator(validate)

    def get_prompt_tokens() -> List[Tuple[Text, Text]]:
        return [("class:qmark", qmark), ("class:question", " {} ".format(message))]

    p = PromptSession(
        get_prompt_tokens, style=merged_style, validator=validator, **kwargs
    )
    p.default_buffer.reset(Document(default))

    return Question(p.app)
github layday / instawow / instawow / prompts.py View on Github external
    @bindings.add('o', eager=True)
    def open_url(event: Any):
        pkg = ic.get_pointed_at().pkg
        if pkg:
            import webbrowser

            webbrowser.open(pkg.url)

    @bindings.add(Keys.Any)
    def other(event: Any):
        # Disallow inserting other text
        pass

    layout = create_inquirer_layout(ic, get_prompt_tokens, **prompt_kwargs)
    app = Application(layout=layout, key_bindings=bindings, style=qstyle, **prompt_kwargs)
    return Question(app)