diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-05 04:45:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-05 04:45:14 +0000 |
commit | 5b43aaac61ac94abe722bc98ae58468618f2f512 (patch) | |
tree | 3d58c89faa23d194f83abb24ae1fd05067538fff /examples/prompts/bottom-toolbar.py | |
parent | Adding upstream version 3.0.43. (diff) | |
download | prompt-toolkit-5b43aaac61ac94abe722bc98ae58468618f2f512.tar.xz prompt-toolkit-5b43aaac61ac94abe722bc98ae58468618f2f512.zip |
Adding upstream version 3.0.46.upstream/3.0.46
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'examples/prompts/bottom-toolbar.py')
-rwxr-xr-x | examples/prompts/bottom-toolbar.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/examples/prompts/bottom-toolbar.py b/examples/prompts/bottom-toolbar.py index 4980e5b..937a961 100755 --- a/examples/prompts/bottom-toolbar.py +++ b/examples/prompts/bottom-toolbar.py @@ -10,6 +10,7 @@ The bottom toolbar will always receive the style 'bottom-toolbar', and the text inside will get 'bottom-toolbar.text'. These can be used to change the default style. """ + import time from prompt_toolkit import prompt @@ -20,14 +21,14 @@ from prompt_toolkit.styles import Style def main(): # Example 1: fixed text. text = prompt("Say something: ", bottom_toolbar="This is a toolbar") - print("You said: %s" % text) + print(f"You said: {text}") # Example 2: fixed text from a callable: def get_toolbar(): - return "Bottom toolbar: time=%r" % time.time() + return f"Bottom toolbar: time={time.time()!r}" text = prompt("Say something: ", bottom_toolbar=get_toolbar, refresh_interval=0.5) - print("You said: %s" % text) + print(f"You said: {text}") # Example 3: Using HTML: text = prompt( @@ -36,7 +37,7 @@ def main(): '(html) <b>This</b> <u>is</u> a <style bg="ansired">toolbar</style>' ), ) - print("You said: %s" % text) + print(f"You said: {text}") # Example 4: Using ANSI: text = prompt( @@ -45,7 +46,7 @@ def main(): "(ansi): \x1b[1mThis\x1b[0m \x1b[4mis\x1b[0m a \x1b[91mtoolbar" ), ) - print("You said: %s" % text) + print(f"You said: {text}") # Example 5: styling differently. style = Style.from_dict( @@ -56,7 +57,7 @@ def main(): ) text = prompt("Say something: ", bottom_toolbar="This is a toolbar", style=style) - print("You said: %s" % text) + print(f"You said: {text}") # Example 6: Using a list of tokens. def get_bottom_toolbar(): @@ -69,11 +70,11 @@ def main(): ] text = prompt("Say something: ", bottom_toolbar=get_bottom_toolbar) - print("You said: %s" % text) + print(f"You said: {text}") # Example 7: multiline fixed text. text = prompt("Say something: ", bottom_toolbar="This is\na multiline toolbar") - print("You said: %s" % text) + print(f"You said: {text}") if __name__ == "__main__": |