diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 16:35:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 16:35:31 +0000 |
commit | 4f1a3b5f9ad05aa7b08715d48909a2b06ee2fcb1 (patch) | |
tree | e5dee7be2f0d963da4faad6517278d03783e3adc /examples/full-screen/simple-demos/vertical-split.py | |
parent | Initial commit. (diff) | |
download | prompt-toolkit-7636d8a881b219a91fe81306e0a97e2eb8be010b.tar.xz prompt-toolkit-7636d8a881b219a91fe81306e0a97e2eb8be010b.zip |
Adding upstream version 3.0.43.upstream/3.0.43
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'examples/full-screen/simple-demos/vertical-split.py')
-rwxr-xr-x | examples/full-screen/simple-demos/vertical-split.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/examples/full-screen/simple-demos/vertical-split.py b/examples/full-screen/simple-demos/vertical-split.py new file mode 100755 index 0000000..b48d106 --- /dev/null +++ b/examples/full-screen/simple-demos/vertical-split.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python +""" +Vertical split example. +""" +from prompt_toolkit.application import Application +from prompt_toolkit.key_binding import KeyBindings +from prompt_toolkit.layout.containers import VSplit, Window +from prompt_toolkit.layout.controls import FormattedTextControl +from prompt_toolkit.layout.layout import Layout + +# 1. The layout +left_text = "\nVertical-split example. Press 'q' to quit.\n\n(left pane.)" +right_text = "\n(right pane.)" + + +body = VSplit( + [ + Window(FormattedTextControl(left_text)), + Window(width=1, char="|"), # Vertical line in the middle. + Window(FormattedTextControl(right_text)), + ] +) + + +# 2. Key bindings +kb = KeyBindings() + + +@kb.add("q") +def _(event): + "Quit application." + event.app.exit() + + +# 3. The `Application` +application = Application(layout=Layout(body), key_bindings=kb, full_screen=True) + + +def run(): + application.run() + + +if __name__ == "__main__": + run() |