Improve alerts positioning
This commit is contained in:
parent
e94062158a
commit
5090e8068d
20
main.py
20
main.py
@ -33,6 +33,8 @@ import time
|
||||
|
||||
locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8')
|
||||
|
||||
NEXT_STOP_Y = 255
|
||||
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
class WidgetPlacement:
|
||||
@ -86,7 +88,7 @@ def main(only_on_coming_evt=False, ignore_module=[], force_coming_event=True, **
|
||||
if evt_coming:
|
||||
from modules.ratp import RATPNextStopModule
|
||||
nstops, nalerts = RATPNextStopModule().draw_module(config, ["RB/cite+universitaire", "M7/porte+d+italie", "B125/raspail+++jean+jaures+++saint+eloi"], int(480/1.6), 275)
|
||||
image.paste(nstops, (480-int(480/1.6), 255))
|
||||
image.paste(nstops, (480-int(480/1.6), NEXT_STOP_Y))
|
||||
occuped_space = nstops.height
|
||||
alerts += nalerts
|
||||
elif only_on_coming_evt:
|
||||
@ -96,7 +98,7 @@ def main(only_on_coming_evt=False, ignore_module=[], force_coming_event=True, **
|
||||
if occuped_space < 250:
|
||||
# weekly weather
|
||||
from modules.weather import WeeklyWeatherModule
|
||||
shape.append(WidgetPlacement(WeeklyWeatherModule, size=(int(480/1.6), 275), position=(480-int(480/1.6), 255 + occuped_space)))
|
||||
shape.append(WidgetPlacement(WeeklyWeatherModule, size=(int(480/1.6), 275), position=(480-int(480/1.6), NEXT_STOP_Y + occuped_space + (5 if occuped_space else 0))))
|
||||
|
||||
# RATP weather
|
||||
from modules.ratp import RATPWeatherModule
|
||||
@ -147,19 +149,19 @@ def main(only_on_coming_evt=False, ignore_module=[], force_coming_event=True, **
|
||||
|
||||
|
||||
from modules import AlertsModule
|
||||
mod = AlertsModule(alerts, ignore_module).draw_module(config, 480, 330)
|
||||
if mod.height > 260:
|
||||
image.paste(mod, (0, 580-mod.height+67), mod)
|
||||
mod = AlertsModule(alerts, ignore_module).draw_module(config, 480, min(317, 640 - NEXT_STOP_Y - occuped_space))
|
||||
if NEXT_STOP_Y + occuped_space + mod.height > 580 or mod.height > 260:
|
||||
image.paste(mod, (0, 640-mod.height), mod)
|
||||
elif mod.height < 100:
|
||||
image.paste(mod, (0, 580-mod.height-40), mod)
|
||||
image.paste(mod, (0, 542-mod.height), mod)
|
||||
else:
|
||||
image.paste(mod, (0, 580-mod.height-5), mod)
|
||||
image.paste(mod, (0, 580-mod.height), mod)
|
||||
|
||||
# températures
|
||||
if "WeatherTemperatureModule" not in ignore_module:
|
||||
from modules.weather import WeatherTemperatureModule
|
||||
if mod.height > 260:
|
||||
image.paste(WeatherTemperatureModule().draw_module(config, 480, 200 - mod.height+260), (0, 580 + mod.height-260))
|
||||
if NEXT_STOP_Y + occuped_space + mod.height > 580 or mod.height > 260:
|
||||
image.paste(WeatherTemperatureModule().draw_module(config, 480, 140), (0, 640))
|
||||
else:
|
||||
image.paste(WeatherTemperatureModule().draw_module(config, 480, 200), (0, 580))
|
||||
|
||||
|
@ -347,6 +347,7 @@ class RATPNextStopModule:
|
||||
"icon": "wi-earthquake.png",
|
||||
})
|
||||
|
||||
align -= int(line_height * 0.33)
|
||||
image = image.crop((0,0,width, min(align, height)))
|
||||
|
||||
return image, alerts
|
||||
|
Loading…
x
Reference in New Issue
Block a user