-
Notifications
You must be signed in to change notification settings - Fork 3
/
example.py
27 lines (20 loc) · 840 Bytes
/
example.py
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
import sys
from curtsies.fmtfuncs import blue, red, bold, on_red
from curtsies.window import Window
from curtsies.terminal import Terminal
if __name__ == '__main__':
print(blue('hey') + ' ' + red('there') + ' ' + red(bold('you')))
with Terminal(sys.stdin, sys.stdout) as tc:
with Window(tc) as t:
rows, columns = t.tc.get_screen_size()
while True:
c = t.tc.get_event()
if c == "":
sys.exit() # same as raise SystemExit()
elif c == "a":
a = [blue(on_red(c*columns)) for _ in range(rows)]
elif c == "b":
a = t.array_from_text("a small array")
else:
a = t.array_from_text("try a, b, or ctrl-D")
t.render_to_terminal(a)