Skip to content

Commit 900e5d7

Browse files
docs cleanup.
1 parent 3f65292 commit 900e5d7

File tree

6 files changed

+41
-15
lines changed

6 files changed

+41
-15
lines changed

docs/images/prompt-with-frame.png

50.5 KB
Loading

docs/pages/asking_for_a_choice.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ Further, we can pass a :class:`~prompt_toolkit.styles.Style` instance using the
3737

3838
.. code:: python
3939
40-
from __future__ import annotations
41-
4240
from prompt_toolkit.formatted_text import HTML
4341
from prompt_toolkit.shortcuts import choice
4442
from prompt_toolkit.styles import Style

docs/pages/asking_for_input.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,42 @@ input mode.
997997
prompt(">", cursor=ModalCursorShapeConfig())
998998
999999
1000+
Adding a frame
1001+
--------------
1002+
1003+
A frame can be displayed around the input by passing ``show_frame=True`` as a
1004+
parameter. The color of the frame can be chosen by styling the ``frame.border``
1005+
element:
1006+
1007+
.. code:: python
1008+
1009+
from prompt_toolkit import prompt
1010+
from prompt_toolkit.styles import Style
1011+
1012+
style = Style.from_dict(
1013+
{
1014+
"frame.border": "#884444",
1015+
}
1016+
)
1017+
1018+
answer = prompt("Say something > ", style=style, show_frame=True)
1019+
print(f"You said: {answer}")
1020+
1021+
.. image:: ../images/prompt-with-frame.png
1022+
1023+
It is also possible to pass a :ref:`filter <filters>`, for instance
1024+
``show_frame=~is_done``, so that the frame is only displayed when asking for
1025+
input, but hidden once the input is accepted.
1026+
1027+
.. code:: python
1028+
1029+
from prompt_toolkit import prompt
1030+
from prompt_toolkit.filters import is_done
1031+
1032+
answer = prompt("Say something > ", show_frame=~is_done)
1033+
print(f"You said: {answer}")
1034+
1035+
10001036
Prompt in an `asyncio` application
10011037
----------------------------------
10021038

examples/prompts/with-frames/frame-and-autocompletion.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
#!/usr/bin/env python
22
"""
3-
Autocompletion example.
4-
5-
Press [Tab] to complete the current word.
6-
- The first Tab press fills in the common part of all completions
7-
and shows all the completions. (In the menu)
8-
- Any following tab press cycles through all the possible completions.
3+
Example of a frame around a prompt input that has autocompletion and a bottom
4+
toolbar.
95
"""
106

117
from prompt_toolkit import prompt

examples/prompts/with-frames/gray-frame-on-accept.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
#!/usr/bin/env python
22
"""
3-
Autocompletion example.
4-
5-
Press [Tab] to complete the current word.
6-
- The first Tab press fills in the common part of all completions
7-
and shows all the completions. (In the menu)
8-
- Any following tab press cycles through all the possible completions.
3+
Example of a frame around a prompt input that has autocompletion and a bottom
4+
toolbar.
95
"""
106

117
from prompt_toolkit import prompt

examples/prompts/with-frames/with-frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22
"""
3-
Example of a colored prompt.
3+
Example of a frame around a prompt input.
44
"""
55

66
from prompt_toolkit import prompt

0 commit comments

Comments
 (0)