Skip to content

Commit 70f9d66

Browse files
rename to "choice".
1 parent 00e8ce4 commit 70f9d66

File tree

11 files changed

+29
-28
lines changed

11 files changed

+29
-28
lines changed

docs/pages/choice_prompts.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ Asking for a choice
55

66
Similar to how the :func:`~prompt_toolkit.shortcuts.prompt` function allows for
77
text input, prompt_toolkit has a
8-
:func:`~prompt_toolkit.shortcuts.prompt_choice` function to ask for a choice
8+
:func:`~prompt_toolkit.shortcuts.choice` function to ask for a choice
99
from a list of options:
1010

1111
.. code:: python
1212
13-
from prompt_toolkit.shortcuts import prompt_choice
13+
from prompt_toolkit.shortcuts import choice
1414
15-
result = prompt_choice(
15+
result = choice(
1616
message="Please choose a dish",
1717
options=[
1818
("pizza", "Pizza with mushrooms"),
@@ -40,7 +40,7 @@ styles. The ``message`` parameter takes any :ref:`formatted text
4040
from __future__ import annotations
4141
4242
from prompt_toolkit.formatted_text import HTML
43-
from prompt_toolkit.shortcuts import prompt_choice
43+
from prompt_toolkit.shortcuts import choice
4444
from prompt_toolkit.styles import Style
4545
4646
style = Style.from_dict(
@@ -52,7 +52,7 @@ styles. The ``message`` parameter takes any :ref:`formatted text
5252
}
5353
)
5454
55-
result = prompt_choice(
55+
result = choice(
5656
message=HTML("<u>Please select a dish</u>:"),
5757
options=[
5858
("pizza", "Pizza with mushrooms"),
@@ -70,15 +70,15 @@ styles. The ``message`` parameter takes any :ref:`formatted text
7070
Adding a frame
7171
--------------
7272

73-
The :func:`~prompt_toolkit.shortcuts.prompt_choice` function takes a
73+
The :func:`~prompt_toolkit.shortcuts.choice` function takes a
7474
``show_frame`` argument. When set to ``True``, the options will be shown
7575
inside a frame. It is also possible to pass a :ref:`filter <filters>`, like
7676
``~is_done``, so that the frame is only displayed when asking for input, but
7777
hidden once the input is accepted.
7878

7979
.. code:: python
8080
81-
from prompt_toolkit.shortcuts import prompt_choice
81+
from prompt_toolkit.shortcuts import choice
8282
from prompt_toolkit.filters import is_done
8383
from prompt_toolkit.styles import Style
8484
@@ -88,7 +88,7 @@ hidden once the input is accepted.
8888
"selected-option": "bold underline",
8989
}
9090
)
91-
result = prompt_choice(
91+
result = choice(
9292
message="Please select a dish:",
9393
options=[
9494
("pizza", "Pizza with mushrooms"),

examples/choice-prompts/color.py renamed to examples/choices/color.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from prompt_toolkit.formatted_text import HTML
4-
from prompt_toolkit.shortcuts import prompt_choice
4+
from prompt_toolkit.shortcuts import choice
55
from prompt_toolkit.styles import Style
66

77

@@ -15,7 +15,7 @@ def main() -> None:
1515
}
1616
)
1717

18-
result = prompt_choice(
18+
result = choice(
1919
message=HTML("<u>Please select a dish</u>:"),
2020
options=[
2121
("pizza", "Pizza with mushrooms"),

examples/choice-prompts/default.py renamed to examples/choices/default.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from __future__ import annotations
22

33
from prompt_toolkit.formatted_text import HTML
4-
from prompt_toolkit.shortcuts import prompt_choice
4+
from prompt_toolkit.shortcuts import choice
55

66

77
def main() -> None:
8-
result = prompt_choice(
8+
result = choice(
99
message=HTML("<u>Please select a dish</u>:"),
1010
options=[
1111
("pizza", "Pizza with mushrooms"),

examples/choice-prompts/gray-frame-on-accept.py renamed to examples/choices/gray-frame-on-accept.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from prompt_toolkit.formatted_text import HTML
4-
from prompt_toolkit.shortcuts import prompt_choice
4+
from prompt_toolkit.shortcuts import choice
55
from prompt_toolkit.styles import Style
66

77

@@ -14,7 +14,7 @@ def main() -> None:
1414
}
1515
)
1616

17-
result = prompt_choice(
17+
result = choice(
1818
message=HTML("<u>Please select a dish</u>:"),
1919
options=[
2020
("pizza", "Pizza with mushrooms"),

examples/choice-prompts/many-options.py renamed to examples/choices/many-choices.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from __future__ import annotations
22

3-
from prompt_toolkit.shortcuts import prompt_choice
3+
from prompt_toolkit.shortcuts import choice
44

55

66
def main() -> None:
7-
result = prompt_choice(
7+
result = choice(
88
message="Please select an option:",
99
options=[(i, f"Option {i}") for i in range(1, 100)],
1010
)

examples/choice-prompts/mouse-support.py renamed to examples/choices/mouse-support.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from __future__ import annotations
22

33
from prompt_toolkit.formatted_text import HTML
4-
from prompt_toolkit.shortcuts import prompt_choice
4+
from prompt_toolkit.shortcuts import choice
55

66

77
def main() -> None:
8-
result = prompt_choice(
8+
result = choice(
99
message=HTML("<u>Please select a dish</u>:"),
1010
options=[
1111
("pizza", "Pizza with mushrooms"),

examples/choice-prompts/simple-selection.py renamed to examples/choices/simple-selection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from __future__ import annotations
22

3-
from prompt_toolkit.shortcuts import prompt_choice
3+
from prompt_toolkit.shortcuts import choice
44

55

66
def main() -> None:
7-
result = prompt_choice(
7+
result = choice(
88
message="Please select a dish:",
99
options=[
1010
("pizza", "Pizza with mushrooms"),

examples/choice-prompts/with-frame.py renamed to examples/choices/with-frame.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from prompt_toolkit.filters import is_done
44
from prompt_toolkit.formatted_text import HTML
5-
from prompt_toolkit.shortcuts import prompt_choice
5+
from prompt_toolkit.shortcuts import choice
66
from prompt_toolkit.styles import Style
77

88

@@ -14,7 +14,7 @@ def main() -> None:
1414
}
1515
)
1616

17-
result = prompt_choice(
17+
result = choice(
1818
message=HTML("<u>Please select a dish</u>:"),
1919
options=[
2020
("pizza", "Pizza with mushrooms"),

src/prompt_toolkit/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
)
2727
from .application import Application
2828
from .formatted_text import ANSI, HTML
29-
from .shortcuts import PromptSession, print_formatted_text, prompt
29+
from .shortcuts import PromptSession, choice, print_formatted_text, prompt
3030

3131
# Don't forget to update in `docs/conf.py`!
3232
__version__ = metadata.version("prompt_toolkit")
@@ -42,6 +42,7 @@
4242
"Application",
4343
# Shortcuts.
4444
"prompt",
45+
"choice",
4546
"PromptSession",
4647
"print_formatted_text",
4748
# Formatted text.

src/prompt_toolkit/shortcuts/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from .choice import prompt_choice
3+
from .choice_input import choice
44
from .dialogs import (
55
button_dialog,
66
checkboxlist_dialog,
@@ -39,7 +39,7 @@
3939
"ProgressBar",
4040
"ProgressBarCounter",
4141
# Choice selection.
42-
"prompt_choice",
42+
"choice",
4343
# Utils.
4444
"clear",
4545
"clear_title",

0 commit comments

Comments
 (0)