summaryrefslogtreecommitdiffstats
path: root/examples/full-screen/hello-world.py
blob: b818018955cda83912c6d778017218bf7c8a799d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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()