-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathheader.py
32 lines (22 loc) · 942 Bytes
/
header.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
from context import Screen, ScreenContext
import time
class Header:
def render_header(self, ctx, tab, tab_name, tab_count):
# Print top row (tab name)
ctx.home().bg_color(Screen.RED).fg_color(Screen.WHITE).write(tab_name)
columns = ctx.get_columns() - len(tab_name)
empty_line = ""
for i in range(0, columns):
empty_line += " "
ctx.write(empty_line)
# Print bottom row (tabs)
characters_drawn = 0
ctx.write("%d / %d" % (tab+1, tab_count))
time_str = time.strftime("%H:%M")
columns = ctx.get_columns() - len("%d / %d" % (tab+1, tab_count)) - len(time_str)
empty_line = ""
for i in range(0, columns):
empty_line += " "
# Draw the time
ctx.write(empty_line + time_str)
ctx.bg_color(Screen.BLACK)