-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
50 lines (42 loc) · 1.39 KB
/
test.py
File metadata and controls
50 lines (42 loc) · 1.39 KB
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
45
46
47
48
49
50
#!/usr/bin/env python3
#
# This file contains a simple test program for demonstrating some basic Python
# BTUI usage.
#
import btui
with btui.open() as bt:
key = None
x, y = 1, 1
while key != 'q' and key != 'Ctrl-c':
if key == '?':
with bt.disabled():
input("Press enter to continue.")
elif key == 'Ctrl-z':
bt.suspend()
with bt.batch():
bt.clear()
with bt.fg(.8, .95, .2):
bt.outline_box(x, y, 30, 1)
bt.move(x, y)
bt.write(f"Pressed: {key}")
title = "Python BTUI Demo"
w = len(title)
center = (bt.width - w) // 2
with bt.attributes("fg_blue", "bg_normal"):
bt.draw_shadow(center - 2, 0, w + 4, 3)
with bt.attributes("bg_blue", "fg_black"):
bt.fill_box(center - 2, 0, w + 4, 3)
bt.move(center, 1)
bt.write(title)
with bt.attributes("bold"):
bt.move(0, bt.height-1)
bt.write("Press 'q' to quit")
with bt.attributes("faint"):
s = f"Size: ({bt.width}x{bt.height})"
bt.move(bt.width-len(s), bt.height-1)
bt.write(s)
key, mx, my = bt.getkey()
if mx:
x, y = mx, my
if key == 'Ctrl-c':
raise KeyboardInterrupt