File: rawlist.py

package info (click to toggle)
python-inquirerpy 0.3.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,088 kB
  • sloc: python: 9,463; makefile: 15
file content (43 lines) | stat: -rw-r--r-- 1,184 bytes parent folder | download | duplicates (2)
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
from InquirerPy import prompt
from InquirerPy.base.control import Choice
from InquirerPy.separator import Separator


def main():
    questions = [
        {
            "type": "rawlist",
            "choices": [
                "Apple",
                "Orange",
                "Peach",
                "Cherry",
                "Melon",
                "Strawberry",
                "Grapes",
            ],
            "message": "Pick your favourites:",
            "default": 3,
            "multiselect": True,
            "transformer": lambda result: ", ".join(result),
            "validate": lambda result: len(result) > 1,
            "invalid_message": "Minimum 2 selections",
        },
        {
            "type": "rawlist",
            "choices": [
                Choice(name="Delivery", value="dl"),
                Choice(name="Pick Up", value="pk"),
                Separator(line=15 * "*"),
                Choice(name="Car Park", value="cp"),
                Choice(name="Third Party", value="tp"),
            ],
            "message": "Select your preferred method:",
        },
    ]

    result = prompt(questions)


if __name__ == "__main__":
    main()