-
Notifications
You must be signed in to change notification settings - Fork 6
/
gui.py
36 lines (29 loc) · 808 Bytes
/
gui.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
26
27
28
29
30
31
32
33
34
35
36
import time
import curses
class GUI:
def __init__(self):
self.results = {}
self.scr = None
self.frame = 0
def run(self):
curses.wrapper(self.loop)
def update(self, results):
self.results = results
self.render()
def render(self):
if self.scr == None:
return
self.scr.clear()
self.render_results(1, 3)
self.scr.addstr(1, 1, str(self.frame))
self.scr.refresh()
self.frame += 1
def loop(self, scr):
self.scr = scr
while True:
time.sleep(1)
def render_results(self, x, y):
y_offset = 0
for register, value in self.results.items():
self.scr.addstr(y + y_offset, x, f"{register.name}={value}")
y_offset += 1