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 # current
curweather = WeatherAPI().get_currently() 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) image.paste(icon, (int(width*self.middle_align - height), 0), icon)
draw.text( draw.text(

View File

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