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/full-screen/hello-world.py | |
parent | Initial commit. (diff) | |
download | prompt-toolkit-e106bf94eff07d9a59771d9ccc4406421e18ab64.tar.xz prompt-toolkit-e106bf94eff07d9a59771d9ccc4406421e18ab64.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/full-screen/hello-world.py')
-rwxr-xr-x | examples/full-screen/hello-world.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/examples/full-screen/hello-world.py b/examples/full-screen/hello-world.py new file mode 100755 index 0000000..b818018 --- /dev/null +++ b/examples/full-screen/hello-world.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python +""" +A simple example of a a text area displaying "Hello World!". +""" +from prompt_toolkit.application import Application +from prompt_toolkit.key_binding import KeyBindings +from prompt_toolkit.layout import Layout +from prompt_toolkit.widgets import Box, Frame, TextArea + +# Layout for displaying hello world. +# (The frame creates the border, the box takes care of the margin/padding.) +root_container = Box( + Frame( + TextArea( + text="Hello world!\nPress control-c to quit.", + width=40, + height=10, + ) + ), +) +layout = Layout(container=root_container) + + +# Key bindings. +kb = KeyBindings() + + +@kb.add("c-c") +def _(event): + "Quit when control-c is pressed." + event.app.exit() + + +# Build a main application object. +application = Application(layout=layout, key_bindings=kb, full_screen=True) + + +def main(): + application.run() + + +if __name__ == "__main__": + main() |