-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshowstatus.py
34 lines (29 loc) · 1.02 KB
/
showstatus.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
import curses
from curses import wrapper
from widgets import Label
class statuswin:
def __init__(self, xpos, ypos, width, height):
self.win = curses.newwin(height, width, ypos, xpos)
self.height = height
self.width = width
self.xpos = xpos
self.ypos = ypos
self.label = Label(
self.win, 0, 0, self.width - 1, "Status unknown", alignment=1
).draw() # Needs -1 because python curses is stupid :(
def update(self, payload):
try:
if payload[0] != 0:
self.label.update_text("Club is open!").update_attributes(
curses.color_pair(2)
).draw()
else:
self.label.update_text("Club is closed!").update_attributes(
curses.color_pair(1)
).draw()
except:
self.label.update_text("Club is closed!").update_attributes(
curses.color_pair(1)
).draw()
def show(self):
self.win.refresh()