-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmmm.py
79 lines (65 loc) · 2.34 KB
/
mmm.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from meteomoris import *
from pilmoji import Pilmoji
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
width = 800
height = 1000
img = Image.new( mode = "RGB", size = (width, height), color = (255, 255, 255) )
font = ImageFont.truetype("/usr/share/fonts/truetype/freefont/FreeMono.ttf", 30, encoding="unic")
padding = 30
line_between = 25
y = 30
buffer = []
special = get_special_weather_bulletin()
main_msg = get_main_message()
with Pilmoji(img) as pilmoji:
today_forecast = get_today_forecast()
pilmoji.text((padding, y), f'{today_forecast["day"]} {today_forecast["date"]}', (0,0,0), font=font)
y += (line_between * 2)
for k,v in today_forecast.items():
if k.casefold() not in ["date", "day"]:
if k in ["condition"]:
pilmoji.text((padding, y), f'{v}', (0,0,0), font=font)
else:
pilmoji.text((padding, y), f'{k}:{v}', (0,0,0), font=font)
y += line_between
for k,v in get_today_sunrise("mu").items():
pilmoji.text((padding, y), f'{k}:{v}', (0,0,0), font=font)
y += line_between
y += line_between
item = get_today_tides()
print(item)
pilmoji.text((padding, y), f'Tides', (0,0,0),
font=font)
y += line_between
pilmoji.text((padding, y), f'{item[0]} {item[1]}mm', (0,0,0),
font=font)
y += line_between
pilmoji.text((padding, y), f'{item[2]} {item[3]}mm ', (0,0,0),
font=font)
y += line_between
pilmoji.text((padding, y), f'{item[4]} {item[5]}mm', (0,0,0),
font=font)
y += line_between
pilmoji.text((padding, y), f'{item[6]} {item[7]}mm', (0,0,0),
font=font)
y += line_between
y+= line_between
#pilmoji.text((padding, y), main_msg, (0, 0, 0), font)
#y += line_between
# font = ImageFont.truetype("/usr/share/fonts/truetype/freefont/FreeMono.ttf", 20, encoding="unic")
for c in main_msg:
if len(buffer) >= 20:
buffer_str = "".join(buffer)
print(buffer_str)
pilmoji.text((padding, y), buffer_str, (0, 0, 0), font)
buffer = []
y += line_between
buffer.append(c)
else:
buffer.append(c)
print(buffer)
buffer_str = "".join(buffer)
pilmoji.text((padding, y), buffer_str, (0, 0, 0), font)
img.show()