-
Notifications
You must be signed in to change notification settings - Fork 0
/
showsky.py
43 lines (39 loc) · 1.36 KB
/
showsky.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
37
38
39
40
41
42
43
import curses
from datetime import datetime
from widgets import Table, rectangle
class skywin:
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.table = Table(
self.win,
1,
2,
self.width-2,
self.height-3,
[
{ #TYPE
"width": 6,
"text": lambda col, row, entry, data: "ISS" if entry['type'] == "iss" else "Ir%2d" % entry["satellite_num"]
},
{ #BRIGHTNESS
"width": self.width - 2 - 6 - 12,
"text": lambda col, row, entry, data: "%1.1f" % entry["brightness_float"]
},
{ #TIME
"width": 12,
"text": lambda col, row, entry, data: datetime.fromtimestamp(entry['timestamp']).strftime('%a %H:%M:%S')
}
])
self.win.addstr(0, 0, "Sky Events:")
rectangle(self.win,0,1,self.width,self.height-1)
def update(self, sky_data):
try:
self.table.apply_data(sky_data)
except Exception as msg:
self.win.addstr(2, 1, msg)
def show(self):
self.win.refresh()