@@ -13,26 +13,26 @@ from a list of options:
1313 from prompt_toolkit.shortcuts import choice
1414
1515 result = choice(
16- message = " Please choose a dish" ,
16+ message = " Please choose a dish: " ,
1717 options = [
1818 (" pizza" , " Pizza with mushrooms" ),
1919 (" salad" , " Salad with tomatoes" ),
2020 (" sushi" , " Sushi" ),
2121 ],
2222 default = " salad" ,
2323 )
24+ print (f " You have chosen: { result} " )
2425
25- print ( f " You have chosen: { text } " )
26+ .. image :: ../images/choice-input.png
2627
2728
2829Coloring the options
2930--------------------
3031
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
3636:meth: `~prompt_toolkit.styles.Style.from_dict ` function:
3737
3838.. code :: python
@@ -48,7 +48,6 @@ styles. The ``message`` parameter takes any :ref:`formatted text
4848 " input-selection" : " fg:#ff0000" ,
4949 " number" : " fg:#884444 bold" ,
5050 " selected-option" : " underline" ,
51- " frame.border" : " #884444" ,
5251 }
5352 )
5453
@@ -66,15 +65,17 @@ styles. The ``message`` parameter takes any :ref:`formatted text
6665 )
6766 print (result)
6867
68+ .. image :: ../images/colored-choice.png
69+
6970
7071Adding a frame
7172--------------
7273
7374The :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.
7879
7980.. code :: python
8081
@@ -85,7 +86,7 @@ hidden once the input is accepted.
8586 style = Style.from_dict(
8687 {
8788 " frame.border" : " #884444" ,
88- " selected-option" : " bold underline " ,
89+ " selected-option" : " bold" ,
8990 }
9091 )
9192 result = choice(
@@ -100,4 +101,4 @@ hidden once the input is accepted.
100101 )
101102 print (result)
102103
103-
104+ .. image :: ../images/choice-with-frame.png
0 commit comments