@@ -13,26 +13,26 @@ from a list of options:
13
13
from prompt_toolkit.shortcuts import choice
14
14
15
15
result = choice(
16
- message = " Please choose a dish" ,
16
+ message = " Please choose a dish: " ,
17
17
options = [
18
18
(" pizza" , " Pizza with mushrooms" ),
19
19
(" salad" , " Salad with tomatoes" ),
20
20
(" sushi" , " Sushi" ),
21
21
],
22
22
default = " salad" ,
23
23
)
24
+ print (f " You have chosen: { result} " )
24
25
25
- print ( f " You have chosen: { text } " )
26
+ .. image :: ../images/choice-input.png
26
27
27
28
28
29
Coloring the options
29
30
--------------------
30
31
31
- Similar to text input prompts, it is possible to customize the colors and
32
- styles. The ``message `` parameter takes any :ref: `formatted text
33
- <formatted_text>`, and the labels (2nd argument of the options) can also be
34
- :ref: `formatted text <formatted_text >`. Further, we can pass a
35
- :class: `~prompt_toolkit.styles.Style ` instance using the
32
+ It is possible to customize the colors and styles. The ``message `` parameter
33
+ takes any :ref: `formatted text <formatted_text >`, and the labels (2nd argument
34
+ from the options) can be :ref: `formatted text <formatted_text >` as well.
35
+ Further, we can pass a :class: `~prompt_toolkit.styles.Style ` instance using the
36
36
:meth: `~prompt_toolkit.styles.Style.from_dict ` function:
37
37
38
38
.. code :: python
@@ -48,7 +48,6 @@ styles. The ``message`` parameter takes any :ref:`formatted text
48
48
" input-selection" : " fg:#ff0000" ,
49
49
" number" : " fg:#884444 bold" ,
50
50
" selected-option" : " underline" ,
51
- " frame.border" : " #884444" ,
52
51
}
53
52
)
54
53
@@ -66,15 +65,17 @@ styles. The ``message`` parameter takes any :ref:`formatted text
66
65
)
67
66
print (result)
68
67
68
+ .. image :: ../images/colored-choice.png
69
+
69
70
70
71
Adding a frame
71
72
--------------
72
73
73
74
The :func: `~prompt_toolkit.shortcuts.choice ` function takes a
74
- ``show_frame `` argument. When set to ``True ``, the options will be shown
75
- inside a frame. It is also possible to pass a :ref: `filter <filters >`, like
76
- `` ~is_done ``, so that the frame is only displayed when asking for input, but
77
- hidden once the input is accepted.
75
+ ``show_frame `` argument. When ``True ``, the input is displayed within a frame.
76
+ It is also possible to pass a :ref: `filter <filters >`, like `` ~is_done ``, so
77
+ that the frame is only displayed when asking for input, but hidden once the
78
+ input is accepted.
78
79
79
80
.. code :: python
80
81
@@ -85,7 +86,7 @@ hidden once the input is accepted.
85
86
style = Style.from_dict(
86
87
{
87
88
" frame.border" : " #884444" ,
88
- " selected-option" : " bold underline " ,
89
+ " selected-option" : " bold" ,
89
90
}
90
91
)
91
92
result = choice(
@@ -100,4 +101,4 @@ hidden once the input is accepted.
100
101
)
101
102
print (result)
102
103
103
-
104
+ .. image :: ../images/choice-with-frame.png
0 commit comments