File: checkbox_search.py

package info (click to toggle)
python-questionary 2.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 960 kB
  • sloc: python: 3,917; makefile: 66
file content (75 lines) | stat: -rw-r--r-- 1,358 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import questionary
from examples import custom_style_dope

zoo_animals = [
    "Lion",
    "Tiger",
    "Elephant",
    "Giraffe",
    "Zebra",
    "Panda",
    "Kangaroo",
    "Gorilla",
    "Chimpanzee",
    "Orangutan",
    "Hippopotamus",
    "Rhinoceros",
    "Leopard",
    "Cheetah",
    "Polar Bear",
    "Grizzly Bear",
    "Penguin",
    "Flamingo",
    "Peacock",
    "Ostrich",
    "Emu",
    "Koala",
    "Sloth",
    "Armadillo",
    "Meerkat",
    "Lemur",
    "Red Panda",
    "Wolf",
    "Fox",
    "Otter",
    "Sea Lion",
    "Walrus",
    "Seal",
    "Crocodile",
    "Alligator",
    "Python",
    "Boa Constrictor",
    "Iguana",
    "Komodo Dragon",
    "Tortoise",
    "Turtle",
    "Parrot",
    "Toucan",
    "Macaw",
    "Hyena",
    "Jaguar",
    "Anteater",
    "Capybara",
    "Bison",
    "Moose",
]


if __name__ == "__main__":
    toppings = (
        questionary.checkbox(
            "Select animals for your zoo",
            choices=zoo_animals,
            validate=lambda a: (
                True if len(a) > 0 else "You must select at least one zoo animal"
            ),
            style=custom_style_dope,
            use_jk_keys=False,
            use_search_filter=True,
        ).ask()
        or []
    )

    print(
        f"Alright let's create our zoo with following animals: {', '.join(toppings)}."
    )