Skip to content

Commit 48e44ab

Browse files
Renamed to prompt_choice.
1 parent 667a475 commit 48e44ab

File tree

9 files changed

+25
-25
lines changed

9 files changed

+25
-25
lines changed

examples/input_selection/color.py renamed to examples/choice-prompts/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 select_input
4+
from prompt_toolkit.shortcuts import prompt_choice
55
from prompt_toolkit.styles import Style
66

77

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

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

examples/input_selection/default.py renamed to examples/choice-prompts/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 select_input
4+
from prompt_toolkit.shortcuts import prompt_choice
55

66

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

examples/input_selection/gray-frame-on-accept.py renamed to examples/choice-prompts/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 select_input
4+
from prompt_toolkit.shortcuts import prompt_choice
55
from prompt_toolkit.styles import Style
66

77

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

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

examples/input_selection/many-options.py renamed to examples/choice-prompts/many-options.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 select_input
3+
from prompt_toolkit.shortcuts import prompt_choice
44

55

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

examples/input_selection/mouse-support.py renamed to examples/choice-prompts/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 select_input
4+
from prompt_toolkit.shortcuts import prompt_choice
55

66

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

examples/input_selection/simple-selection.py renamed to examples/choice-prompts/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 select_input
3+
from prompt_toolkit.shortcuts import prompt_choice
44

55

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

examples/input_selection/with-frame.py renamed to examples/choice-prompts/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 select_input
5+
from prompt_toolkit.shortcuts import prompt_choice
66
from prompt_toolkit.styles import Style
77

88

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

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

src/prompt_toolkit/shortcuts/__init__.py

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

3+
from .choice import prompt_choice
34
from .dialogs import (
45
button_dialog,
56
checkboxlist_dialog,
@@ -9,7 +10,6 @@
910
radiolist_dialog,
1011
yes_no_dialog,
1112
)
12-
from .input_selection import select_input
1313
from .progress_bar import ProgressBar, ProgressBarCounter
1414
from .prompt import (
1515
CompleteStyle,
@@ -38,8 +38,8 @@
3838
# Progress bars.
3939
"ProgressBar",
4040
"ProgressBarCounter",
41-
# Input selection.
42-
"select_input",
41+
# Choice selection.
42+
"prompt_choice",
4343
# Utils.
4444
"clear",
4545
"clear_title",

src/prompt_toolkit/shortcuts/input_selection.py renamed to src/prompt_toolkit/shortcuts/choice.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
from prompt_toolkit.widgets import Box, Frame, Label, RadioList
1414

1515
__all__ = [
16-
"InputSelection",
17-
"select_input",
16+
"ChoiceInput",
17+
"prompt_choice",
1818
]
1919

2020
_T = TypeVar("_T")
@@ -30,13 +30,13 @@ def create_default_input_selection_style() -> BaseStyle:
3030
)
3131

3232

33-
class InputSelection(Generic[_T]):
33+
class ChoiceInput(Generic[_T]):
3434
"""
3535
Input selection prompt. Ask the user to choose among a set of options.
3636
3737
Example usage::
3838
39-
input_selection = InputSelection(
39+
input_selection = ChoiceInput(
4040
message="Please select a dish:",
4141
options=[
4242
("pizza", "Pizza with mushrooms"),
@@ -176,7 +176,7 @@ async def prompt_async(self) -> _T:
176176
return await self._create_application().run_async()
177177

178178

179-
def select_input(
179+
def prompt_choice(
180180
message: AnyFormattedText,
181181
options: Sequence[tuple[_T, AnyFormattedText]],
182182
default: _T | None = None,
@@ -189,11 +189,11 @@ def select_input(
189189
interrupt_exception: type[BaseException] = KeyboardInterrupt,
190190
) -> _T:
191191
"""
192-
Input selection prompt. Ask the user to choose among a set of options.
192+
Choice selection prompt. Ask the user to choose among a set of options.
193193
194194
Example usage::
195195
196-
result= select_input(
196+
result= prompt_choice(
197197
message="Please select a dish:",
198198
options=[
199199
("pizza", "Pizza with mushrooms"),
@@ -211,7 +211,7 @@ def select_input(
211211
:param style: :class:`.Style` instance for the color scheme.
212212
"""
213213

214-
return InputSelection[_T](
214+
return ChoiceInput[_T](
215215
message=message,
216216
options=options,
217217
default=default,

0 commit comments

Comments
 (0)