Skip to content

Commit 989c7e0

Browse files
committed
Allow to specify show_numbers in ChoiceInput
Fixes #2058
1 parent 940af53 commit 989c7e0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/prompt_toolkit/shortcuts/choice_input.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class ChoiceInput(Generic[_T]):
8080
:param show_frame: `bool` or
8181
:class:`~prompt_toolkit.filters.Filter`. When True, surround the input
8282
with a frame.
83+
:param show_numbers: Whether to show the option numbers in front of each choice.
8384
:param enable_interrupt: `bool` or
8485
:class:`~prompt_toolkit.filters.Filter`. When True, raise
8586
the ``interrupt_exception`` (``KeyboardInterrupt`` by default) when
@@ -99,6 +100,7 @@ def __init__(
99100
symbol: str = ">",
100101
bottom_toolbar: AnyFormattedText = None,
101102
show_frame: FilterOrBool = False,
103+
show_numbers: bool = True,
102104
enable_suspend: FilterOrBool = False,
103105
enable_interrupt: FilterOrBool = True,
104106
interrupt_exception: type[BaseException] = KeyboardInterrupt,
@@ -114,6 +116,7 @@ def __init__(
114116
self.style = style
115117
self.symbol = symbol
116118
self.show_frame = show_frame
119+
self.show_numbers = show_numbers
117120
self.enable_suspend = enable_suspend
118121
self.interrupt_exception = interrupt_exception
119122
self.enable_interrupt = enable_interrupt
@@ -129,7 +132,7 @@ def _create_application(self) -> Application[_T]:
129132
select_character=self.symbol,
130133
close_character="",
131134
show_cursor=False,
132-
show_numbers=True,
135+
show_numbers=self.show_numbers,
133136
container_style="class:input-selection",
134137
default_style="class:option",
135138
selected_style="",

0 commit comments

Comments
 (0)