diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 17:35:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 17:35:20 +0000 |
commit | e106bf94eff07d9a59771d9ccc4406421e18ab64 (patch) | |
tree | edb6545500e39df9c67aa918a6125bffc8ec1aee /examples/dialogs/checkbox_dialog.py | |
parent | Initial commit. (diff) | |
download | prompt-toolkit-0a3e0a12a3f6453f8e5b1cffb2f7e1e619420f44.tar.xz prompt-toolkit-0a3e0a12a3f6453f8e5b1cffb2f7e1e619420f44.zip |
Adding upstream version 3.0.36.upstream/3.0.36upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'examples/dialogs/checkbox_dialog.py')
-rwxr-xr-x | examples/dialogs/checkbox_dialog.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/examples/dialogs/checkbox_dialog.py b/examples/dialogs/checkbox_dialog.py new file mode 100755 index 0000000..90be263 --- /dev/null +++ b/examples/dialogs/checkbox_dialog.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python +""" +Example of a checkbox-list-based dialog. +""" +from prompt_toolkit.formatted_text import HTML +from prompt_toolkit.shortcuts import checkboxlist_dialog, message_dialog +from prompt_toolkit.styles import Style + +results = checkboxlist_dialog( + title="CheckboxList dialog", + text="What would you like in your breakfast ?", + values=[ + ("eggs", "Eggs"), + ("bacon", HTML("<blue>Bacon</blue>")), + ("croissants", "20 Croissants"), + ("daily", "The breakfast of the day"), + ], + style=Style.from_dict( + { + "dialog": "bg:#cdbbb3", + "button": "bg:#bf99a4", + "checkbox": "#e8612c", + "dialog.body": "bg:#a9cfd0", + "dialog shadow": "bg:#c98982", + "frame.label": "#fcaca3", + "dialog.body label": "#fd8bb6", + } + ), +).run() +if results: + message_dialog( + title="Room service", + text="You selected: %s\nGreat choice sir !" % ",".join(results), + ).run() +else: + message_dialog("*starves*").run() |