File: expand.py

package info (click to toggle)
python-inquirerpy 0.3.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,088 kB
  • sloc: python: 9,463; makefile: 15
file content (48 lines) | stat: -rw-r--r-- 1,381 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from InquirerPy import prompt
from InquirerPy.prompts.expand import ExpandChoice
from InquirerPy.separator import Separator


def question1_choice(_):
    return [
        ExpandChoice(key="a", name="Apple", value="Apple"),
        ExpandChoice(key="c", name="Cherry", value="Cherry"),
        ExpandChoice(key="o", name="Orange", value="Orange"),
        ExpandChoice(key="p", name="Peach", value="Peach"),
        ExpandChoice(key="m", name="Melon", value="Melon"),
        ExpandChoice(key="s", name="Strawberry", value="Strawberry"),
        ExpandChoice(key="g", name="Grapes", value="Grapes"),
    ]


def question2_choice(_):
    return [
        ExpandChoice(key="d", name="Delivery", value="dl"),
        ExpandChoice(key="p", name="Pick Up", value="pk"),
        Separator(line=15 * "*"),
        ExpandChoice(key="c", name="Car Park", value="cp"),
        ExpandChoice(key="t", name="Third Party", value="tp"),
    ]


def main():
    questions = [
        {
            "type": "expand",
            "choices": question1_choice,
            "message": "Pick your favourite:",
            "default": "o",
            "cycle": False,
        },
        {
            "type": "expand",
            "choices": question2_choice,
            "message": "Select your preferred method:",
        },
    ]

    result = prompt(questions)


if __name__ == "__main__":
    main()