Differentiate current weather icons from weekly prevision

This commit is contained in:
nemunaire 2022-08-12 12:48:54 +02:00
parent 9e15da095b
commit cac484840e
2 changed files with 30 additions and 9 deletions

View File

@ -114,7 +114,7 @@ class WeatherJumboCurrentModule:
# current
curweather = WeatherAPI().get_currently()
icon = Image.open("icons/" + WeatherAPI.get_icon(curweather["icon"])).resize((height, height))
icon = Image.open("icons/" + WeatherAPI.get_icon(curweather["icon"], current=True)).resize((height, height))
image.paste(icon, (int(width*self.middle_align - height), 0), icon)
draw.text(

View File

@ -40,21 +40,36 @@ class DarkSkyAPI:
return res
def get_icon(icon):
def get_icon(icon, current=False):
if icon == "clear-day":
return "wi-day-sunny.png"
elif icon == "clear-night":
return "wi-night-clear.png"
elif icon == "rain":
if not current:
return "wi-day-rain.png"
else:
return "wi-rain.png"
elif icon == "snow":
if not current:
return "wi-day-snow.png"
else:
return "wi-snow.png"
elif icon == "sleet":
if not current:
return "wi-day-sleet.png"
else:
return "wi-sleet.png"
elif icon == "wind":
if not current:
return "wi-day-windy.png"
else:
return "wi-strong-wind.png"
elif icon == "fog":
if not current:
return "wi-day-fog.png"
else:
return "wi-fog.png"
elif icon == "cloudy":
return "wi-cloudy.png"
elif icon == "partly-cloudy-day":
@ -62,8 +77,14 @@ class DarkSkyAPI:
elif icon == "partly-cloudy-night":
return "wi-night-partly-cloudy.png"
elif icon == "hail":
if not current:
return "wi-day-hail.png"
else:
return "wi-hail.png"
elif icon == "thunderstorm":
if not current:
return "wi-day-thunderstorm.png"
else:
return "wi-thunderstorm.png"
elif icon == "tornado":
return "wi-tornado.png"