summaryrefslogtreecommitdiffstats
path: root/examples/full-screen/simple-demos/vertical-split.py
blob: b48d1063eb552672ef97fbfee438f3473289b994 (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
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()