disable enable current weather, fixed spacing
This commit is contained in:
parent
ced479f28f
commit
8ab7361a57
171
stockTicker.py
171
stockTicker.py
@ -4146,15 +4146,13 @@ class StockTicker():
|
||||
f = open('csv/daily_weather.json', 'r')
|
||||
all_settings = json.load(f)
|
||||
f.close()
|
||||
|
||||
|
||||
|
||||
if all_settings['title']:
|
||||
title_img = self.openImage('feature_titles/forecast.png')
|
||||
imgs = [title_img, self.blank]
|
||||
else:
|
||||
imgs = []
|
||||
|
||||
|
||||
|
||||
f = open('csv/daily_weather.json', 'r')
|
||||
daily_weathers = json.load(f)
|
||||
f.close()
|
||||
@ -4163,16 +4161,14 @@ class StockTicker():
|
||||
for i, location in enumerate(locations):
|
||||
try:
|
||||
img = Image.new('RGB', (1000, 32))
|
||||
|
||||
|
||||
|
||||
daily_weather = daily_weathers['locations'][location]
|
||||
|
||||
small_font = ImageFont.load("./fonts/5x7.pil")
|
||||
extra_small_font = ImageFont.load("./fonts/4x6.pil")
|
||||
large_font = ImageFont.load("./fonts/10x20.pil")
|
||||
|
||||
|
||||
location_img = self.textImage(location.upper(), extra_small_font, r = 255, g = 255, b = 0)
|
||||
|
||||
location_img = self.textImage(location.upper(), small_font, r = 255, g = 255, b = 0)
|
||||
main = daily_weather[0]['main_weather']
|
||||
if main == 'Clouds':
|
||||
main = daily_weather[0]['description']
|
||||
@ -4187,15 +4183,11 @@ class StockTicker():
|
||||
weather_dir = './logos/weather_icons'
|
||||
|
||||
weather_img = Image.open(weather_dir + '/weather_type_icons/' + weather_ids[main] + '.png')
|
||||
|
||||
|
||||
|
||||
temp = self.convertTemp(daily_weather[0]['temp'], daily_weathers['temp'])
|
||||
min_temp = self.convertTemp(daily_weather[0]['min_temp'], daily_weathers['temp'])
|
||||
max_temp = self.convertTemp(daily_weather[0]['max_temp'], daily_weathers['temp'])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
temp_img = self.textImage(str("{0:.0f}".format(temp)), large_font)
|
||||
deg_img = self.textImage('o', small_font)
|
||||
|
||||
@ -4210,39 +4202,35 @@ class StockTicker():
|
||||
month = months[int(datetime.now().strftime('%m'))-1]
|
||||
date = str(int(datetime.now().strftime('%d')))
|
||||
weekday = weekdays[datetime.today().weekday()]
|
||||
date_img = self.textImage((month + ' ' + date + ',' + weekday).upper(), extra_small_font)
|
||||
|
||||
|
||||
rain_img = Image.open(weather_dir + '/rain-chance.png')
|
||||
rtext_img = self.textImage(str(int(daily_weather[0]['rain_chance']*100)) + '%', extra_small_font)
|
||||
hum_img = Image.open(weather_dir + '/humidity.png')
|
||||
htext_img = self.textImage(str(daily_weather[0]['humidity']) + '%', extra_small_font)
|
||||
wind_img = Image.open(weather_dir + '/wind.png')
|
||||
wtext_img = self.textImage(str(daily_weather[0]['wind_speed']) + 'm/s'.upper(), extra_small_font)
|
||||
uv_img = Image.open(weather_dir + '/uv.png')
|
||||
utext_img = self.textImage(str(round(daily_weather[0]['uv'], 1)) , small_font)
|
||||
cloud_img = Image.open(weather_dir + '/clouds.png')
|
||||
ctext_img = self.textImage(str(daily_weather[0]['clouds']) + '%', small_font)
|
||||
wind_img = Image.open(weather_dir + '/wind.png')
|
||||
|
||||
|
||||
w_speed = daily_weather[0]['wind_speed']*3.6
|
||||
w_unit = 'K/H'
|
||||
if daily_weathers['wind_speed'] == "miles/hour":
|
||||
w_speed = daily_weather[0]['wind_speed']*2.236936
|
||||
w_unit = 'M/H'
|
||||
|
||||
|
||||
wtext_img = self.textImage("{0:.0f}".format(w_speed) + w_unit, small_font)
|
||||
wdir_img = self.textImage(self.degreesToCompass(daily_weather[0]['wind_direction']), small_font)
|
||||
vis_img = Image.open(weather_dir + '/visibility.png')
|
||||
vtext_img = self.textImage(str(round(daily_weather[0]['visibility']/1000, 1)) + 'km'.upper(), small_font)
|
||||
|
||||
|
||||
date_img = self.textImage((month + ' ' + date + ',' + weekday).upper(), small_font)
|
||||
|
||||
if daily_weathers['current_weather']:
|
||||
rain_img = Image.open(weather_dir + '/rain-chance.png')
|
||||
rtext_img = self.textImage(str(int(daily_weather[0]['rain_chance']*100)) + '%', small_font)
|
||||
hum_img = Image.open(weather_dir + '/humidity.png')
|
||||
htext_img = self.textImage(str(daily_weather[0]['humidity']) + '%', small_font)
|
||||
wind_img = Image.open(weather_dir + '/wind.png')
|
||||
wtext_img = self.textImage(str(daily_weather[0]['wind_speed']) + 'm/s'.upper(), small_font)
|
||||
uv_img = Image.open(weather_dir + '/uv.png')
|
||||
utext_img = self.textImage(str(round(daily_weather[0]['uv'], 1)) , small_font)
|
||||
cloud_img = Image.open(weather_dir + '/clouds.png')
|
||||
ctext_img = self.textImage(str(daily_weather[0]['clouds']) + '%', small_font)
|
||||
wind_img = Image.open(weather_dir + '/wind.png')
|
||||
|
||||
w_speed = daily_weather[0]['wind_speed']*3.6
|
||||
w_unit = 'K/H'
|
||||
if daily_weathers['wind_speed'] == "miles/hour":
|
||||
w_speed = daily_weather[0]['wind_speed']*2.236936
|
||||
w_unit = 'M/H'
|
||||
|
||||
wtext_img = self.textImage("{0:.0f}".format(w_speed) + w_unit, small_font)
|
||||
wdir_img = self.textImage(self.degreesToCompass(daily_weather[0]['wind_direction']), small_font)
|
||||
vis_img = Image.open(weather_dir + '/visibility.png')
|
||||
vtext_img = self.textImage(str(round(daily_weather[0]['visibility']/1000, 1)) + 'km'.upper(), small_font)
|
||||
|
||||
img.paste(location_img, (0,0))
|
||||
|
||||
x_offset = location_img.size[0]+2
|
||||
|
||||
x_offset2 = location_img.size[0]+5
|
||||
|
||||
img.paste(weather_img, (5,9))
|
||||
x_offset = 5 + weather_img.size[0] + 1
|
||||
@ -4253,79 +4241,66 @@ class StockTicker():
|
||||
img.paste(deg_img, (x_offset + main_img.size[0]//2 - temp_img.size[0]//2 + temp_img.size[0], 8))
|
||||
|
||||
x_offset += max( main_img.size[0], temp_img.size[0] + deg_img.size[0])
|
||||
|
||||
|
||||
|
||||
img.paste(min_img, (x_offset - 0, 12))
|
||||
img.paste(max_img, (x_offset - 0, 21))
|
||||
|
||||
x_offset += max(min_img.size[0], max_img.size[0]) + 2
|
||||
|
||||
img.paste(date_img, (x_offset, 1))
|
||||
x_offset += date_img.size[0]+2
|
||||
img.paste(date_img, (x_offset2, 0))
|
||||
x_offset2 += date_img.size[0]+5
|
||||
|
||||
img.paste(rain_img, (x_offset,0))
|
||||
x_offset += rain_img.size[0]+2
|
||||
img.paste(rtext_img, (x_offset, 1))
|
||||
x_offset += rtext_img.size[0]+2
|
||||
if daily_weathers['current_weather']:
|
||||
img.paste(rain_img, (x_offset2,0))
|
||||
x_offset2 += rain_img.size[0]+2
|
||||
img.paste(rtext_img, (x_offset2,1))
|
||||
x_offset2 += rtext_img.size[0]+2
|
||||
|
||||
img.paste(hum_img, (x_offset2, 0))
|
||||
x_offset2 += hum_img.size[0]+2
|
||||
img.paste(htext_img, (x_offset2, 1))
|
||||
x_offset2+= htext_img.size[0]+2
|
||||
|
||||
img.paste(uv_img, ( x_offset2, 0))
|
||||
x_offset2 += uv_img.size[0]+2
|
||||
img.paste(utext_img, (x_offset2, 1))
|
||||
x_offset2 += utext_img.size[0]+2
|
||||
|
||||
img.paste(cloud_img, (x_offset2,0))
|
||||
x_offset2 += cloud_img.size[0]+2
|
||||
img.paste(ctext_img, (x_offset2, 1))
|
||||
x_offset2 += ctext_img.size[0]+2
|
||||
|
||||
img.paste(wind_img, (x_offset2,0))
|
||||
x_offset2 += wind_img.size[0]+2
|
||||
img.paste(wtext_img, (x_offset2, 1))
|
||||
x_offset2 += wtext_img.size[0]+2
|
||||
img.paste(wdir_img, (x_offset2, 1))
|
||||
x_offset2+= wdir_img.size[0]+2
|
||||
|
||||
img.paste(vis_img, (x_offset2,-1))
|
||||
x_offset2+= vis_img.size[0]+2
|
||||
img.paste(vtext_img, (x_offset2, 1))
|
||||
x_offset2 += vtext_img.size[0] +2
|
||||
|
||||
img.paste(hum_img, (x_offset, 0))
|
||||
x_offset += hum_img.size[0]+2
|
||||
img.paste(htext_img, (x_offset, 1))
|
||||
x_offset+= htext_img.size[0]+2
|
||||
|
||||
img.paste(uv_img, ( x_offset, 0))
|
||||
x_offset += uv_img.size[0]+2
|
||||
img.paste(utext_img, (x_offset, 1))
|
||||
x_offset += utext_img.size[0]+2
|
||||
|
||||
img.paste(cloud_img, (x_offset,0))
|
||||
x_offset += cloud_img.size[0]+2
|
||||
img.paste(ctext_img, (x_offset, 1))
|
||||
x_offset += ctext_img.size[0]+2
|
||||
|
||||
img.paste(wind_img, (x_offset,0))
|
||||
x_offset += wind_img.size[0]+2
|
||||
img.paste(wtext_img, (x_offset, 1))
|
||||
x_offset += wtext_img.size[0]+2
|
||||
img.paste(wdir_img, (x_offset, 1))
|
||||
x_offset+= wdir_img.size[0]+2
|
||||
|
||||
img.paste(vis_img, (x_offset,0))
|
||||
x_offset+= vis_img.size[0]+2
|
||||
img.paste(vtext_img, (x_offset, 1))
|
||||
x_offset += vtext_img.size[0] +2
|
||||
|
||||
crop_x = x_offset
|
||||
#img.paste(uv_img, ( 96, 0))
|
||||
#img.paste(utext_img, (109, 0))
|
||||
#img.paste(wind_img, (96,0))
|
||||
#img.paste(wtext_img, (109,0))
|
||||
#img.paste(date_img, (70, 0))
|
||||
x_offset = 77
|
||||
|
||||
for i in range(1,len(daily_weather)):
|
||||
weekday = weekdays[(datetime.today().weekday() + i)%7]
|
||||
|
||||
day_img = self.textImage( weekday.upper(), small_font)
|
||||
weather = daily_weather[i]
|
||||
main = weather['main_weather']
|
||||
|
||||
|
||||
|
||||
if main == 'Clouds':
|
||||
main = weather['description']
|
||||
if main == 'Rain':
|
||||
main = weather['description']
|
||||
|
||||
|
||||
|
||||
min_temp = self.convertTemp(weather['min_temp'], daily_weathers['temp'])
|
||||
max_temp = self.convertTemp(weather['max_temp'], daily_weathers['temp'])
|
||||
|
||||
|
||||
|
||||
weather_img = Image.open(weather_dir + '/small_icons/' + weather_ids[main] + '.png')
|
||||
min_img = self.textImage( "{0:.0f}".format(min_temp), small_font, r=0, g=0, b=255)
|
||||
|
||||
|
||||
|
||||
max_img = self.textImage( "{0:.0f}".format(max_temp), small_font, r=255, g=0, b=0)
|
||||
|
||||
img.paste(day_img, (x_offset +5, 9))
|
||||
@ -4335,7 +4310,7 @@ class StockTicker():
|
||||
|
||||
x_offset += 43
|
||||
|
||||
img1 = img.crop((0,0,max(x_offset, crop_x) ,32))
|
||||
img1 = img.crop((0,0,max(x_offset, x_offset2 + 10) ,32))
|
||||
imgs.append(img1)
|
||||
imgs.append(self.blank)
|
||||
# add the image text
|
||||
|
Loading…
Reference in New Issue
Block a user