economic calendar standard display
This commit is contained in:
parent
d0dccfce52
commit
e1572cdcd7
133
stockTicker.py
133
stockTicker.py
@ -71,7 +71,7 @@ class StockTicker():
|
|||||||
'Sports (Team Stats)':lambda : self.getLeagueTableImage('premier_league'), 'Sports (Past Games)': lambda:self.getLeagueImage('NBA', 'past'),
|
'Sports (Team Stats)':lambda : self.getLeagueTableImage('premier_league'), 'Sports (Past Games)': lambda:self.getLeagueImage('NBA', 'past'),
|
||||||
'Sports (Upcoming Games)': lambda : self.getLeagueImage('NHL', 'future'), 'Sports (Live Games)': lambda: self.getLeagueImage('NBA', 'live'),
|
'Sports (Upcoming Games)': lambda : self.getLeagueImage('NHL', 'future'), 'Sports (Live Games)': lambda: self.getLeagueImage('NBA', 'live'),
|
||||||
'News':self.getNewsImage, 'Custom Messages': self.getUserMessages, 'Commodities': self.getCommoditiesImage, 'Indices': self.getIndicesImage, 'Movies': self.getMoviesImage,
|
'News':self.getNewsImage, 'Custom Messages': self.getUserMessages, 'Commodities': self.getCommoditiesImage, 'Indices': self.getIndicesImage, 'Movies': self.getMoviesImage,
|
||||||
'IPO Calendar':self.getIpoImage, 'IPO Calendar Prof':self.getIpoProfessional,
|
'Economic Calendar': self.getEconomicImage, 'IPO Calendar':self.getIpoImage, 'IPO Calendar Prof':self.getIpoProfessional,
|
||||||
|
|
||||||
'Stocks Prof': self.getStockProfessional, 'Crypto Prof': self.getCryptoProfessional, 'Forex Prof': self.getForexProfessional,
|
'Stocks Prof': self.getStockProfessional, 'Crypto Prof': self.getCryptoProfessional, 'Forex Prof': self.getForexProfessional,
|
||||||
'Current Weather Prof': self.getTodayWeatherProfessional, 'News Prof':self.getNewsProfessional, 'Commodities Prof':self.getCommoditiesProfessional, 'Indices Prof': self.getIndicesProfessional,
|
'Current Weather Prof': self.getTodayWeatherProfessional, 'News Prof':self.getNewsProfessional, 'Commodities Prof':self.getCommoditiesProfessional, 'Indices Prof': self.getIndicesProfessional,
|
||||||
@ -80,7 +80,7 @@ class StockTicker():
|
|||||||
|
|
||||||
self.JSONs = {'Stocks': 'csv/stocks_settings.json', 'Crypto': 'csv/crypto_settings.json', 'Forex': 'csv/forex_settings.json',
|
self.JSONs = {'Stocks': 'csv/stocks_settings.json', 'Crypto': 'csv/crypto_settings.json', 'Forex': 'csv/forex_settings.json',
|
||||||
'Daily Forecast':'csv/daily_weather.json', 'Current Weather': 'csv/current_weather.json', 'Commodities':'csv/commodities_settings.json', 'Indices': 'csv/indices_settings.json',
|
'Daily Forecast':'csv/daily_weather.json', 'Current Weather': 'csv/current_weather.json', 'Commodities':'csv/commodities_settings.json', 'Indices': 'csv/indices_settings.json',
|
||||||
'Sports (Team Stats)': 'csv/league_tables.json', 'Sports (Past Games)': 'csv/past_games.json', 'IPO Calendar': 'csv/ipo_settings.json',
|
'Sports (Team Stats)': 'csv/league_tables.json', 'Sports (Past Games)': 'csv/past_games.json', 'IPO Calendar': 'csv/ipo_settings.json', 'Economic Calendar': 'csv/economic_settings.json',
|
||||||
'Sports (Upcoming Games)': 'csv/upcoming_games.json', 'Sports (Live Games)': 'csv/live_games.json', 'Movies': 'csv/movie_settings.json',
|
'Sports (Upcoming Games)': 'csv/upcoming_games.json', 'Sports (Live Games)': 'csv/live_games.json', 'Movies': 'csv/movie_settings.json',
|
||||||
'News':'csv/news_settings.json', 'Custom Images': 'csv/image_settings.json', 'Custom GIFs': 'csv/GIF_settings.json', 'Custom Messages': 'csv/message_settings.json',
|
'News':'csv/news_settings.json', 'Custom Images': 'csv/image_settings.json', 'Custom GIFs': 'csv/GIF_settings.json', 'Custom Messages': 'csv/message_settings.json',
|
||||||
'Stocks Prof': 'csv/stocks_settings.json', 'Crypto Prof': 'csv/crypto_settings.json', 'Forex Prof': 'csv/forex_settings.json',
|
'Stocks Prof': 'csv/stocks_settings.json', 'Crypto Prof': 'csv/crypto_settings.json', 'Forex Prof': 'csv/forex_settings.json',
|
||||||
@ -5812,6 +5812,132 @@ class StockTicker():
|
|||||||
return self.stitchImage(image_list)
|
return self.stitchImage(image_list)
|
||||||
|
|
||||||
|
|
||||||
|
def getEconomicImage(self):
|
||||||
|
|
||||||
|
f = open('csv/economic_settings.json', 'r')
|
||||||
|
econ_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
if econ_settings['title']:
|
||||||
|
title_img = self.openImage('feature_titles/economy.png')
|
||||||
|
image_list = [title_img]
|
||||||
|
else:
|
||||||
|
image_list = []
|
||||||
|
|
||||||
|
font = ImageFont.load("./fonts/7x14B.pil")
|
||||||
|
font2 = ImageFont.load("./fonts/6x12.pil")
|
||||||
|
small_font = ImageFont.load("./fonts/6x10.pil")
|
||||||
|
|
||||||
|
if len(econ_settings['events']) != 0:
|
||||||
|
try:
|
||||||
|
for event in econ_settings['events']:
|
||||||
|
if event['importance'] == -1:
|
||||||
|
imp_img = Image.open('logos/low_imp.png')
|
||||||
|
elif event['importance'] == 0:
|
||||||
|
imp_img = Image.open('logos/med_imp.png')
|
||||||
|
elif event['importance'] == 1:
|
||||||
|
imp_img = Image.open('logos/high_imp.png')
|
||||||
|
x_offset = 15
|
||||||
|
if event['period'] != "":
|
||||||
|
clock_img = Image.open('logos/period.png')
|
||||||
|
period_img = self.textImage(event['period'].upper(), small_font, r=255, g= 255, b =255)
|
||||||
|
else:
|
||||||
|
clock_img = None
|
||||||
|
period_img = None
|
||||||
|
flag_img = Image.open('logos/economic_logos/' + event['country'] + '.png')
|
||||||
|
circle_img = Image.open('logos/indicator.png')
|
||||||
|
title_img = self.textImage(event['title'].upper(), font, r = 255, g = 255, b = 255)
|
||||||
|
country_img = self.textImage(event['country'].upper(), font2, r= 255, g = 255, b = 0)
|
||||||
|
date_img = self.textImage(event['time'], small_font, r=0, g=150, b=255)
|
||||||
|
indicator_img = self.textImage(event['indicator'], font2, r=255, g=255, b=255)
|
||||||
|
after_offset = 0
|
||||||
|
if event['forecast'] != None or event['previous'] != None or event['actual'] != None:
|
||||||
|
tiny_font = ImageFont.load("./fonts/5x7.pil")
|
||||||
|
try:
|
||||||
|
if event['forecast'] != None:
|
||||||
|
fore_img = self.textImage('Forecast', tiny_font, r=255,g=255,b=255)
|
||||||
|
fore2_img = self.textImage(str(event['forecast']), tiny_font, r=0, g=255, b=0)
|
||||||
|
after_offset += max(fore_img.size[0], fore2_img.size[0]) + 3
|
||||||
|
if event['previous'] != None:
|
||||||
|
prev_img = self.textImage('Prior', tiny_font, r=255,g=255,b=255)
|
||||||
|
prev2_img = self.textImage(str(event['previous']), tiny_font, r=0, g=255, b=0)
|
||||||
|
after_offset += max(prev_img.size[0], prev2_img.size[0]) + 3
|
||||||
|
actual_img = self.textImage('Actual', tiny_font, r=255,g=255,b=255)
|
||||||
|
if event['actual'] == None:
|
||||||
|
actual2_img = self.textImage('Soon', tiny_font, r=255, g=40, b=40)
|
||||||
|
else:
|
||||||
|
actual2_img = self.textImage(str(event['actual']), tiny_font, r=0, g=255, b=0)
|
||||||
|
after_offset += max(actual_img.size[0], actual2_img.size[0]) + 3
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
img = Image.new('RGB', (
|
||||||
|
max(flag_img.size[0] + x_offset + 5 + 3 + title_img.size[0] + country_img.size[0],
|
||||||
|
max(flag_img.size[0] + x_offset + 5 + 1 + circle_img.size[0] + 2 + indicator_img.size[0] + 2 + imp_img.size[0],
|
||||||
|
flag_img.size[0] + x_offset + 5 + 1 + date_img.size[0] + 3 + 2 + clock_img.size[0] + period_img.size[0]) + 10 + after_offset
|
||||||
|
)
|
||||||
|
,32))
|
||||||
|
except:
|
||||||
|
img = Image.new('RGB', (
|
||||||
|
max(flag_img.size[0] + x_offset + 5 + 3 + title_img.size[0] + country_img.size[0],
|
||||||
|
max(flag_img.size[0] + x_offset + 5 + 1 + circle_img.size[0] + 2 + indicator_img.size[0] + 2 + imp_img.size[0],
|
||||||
|
flag_img.size[0] + x_offset + 5 + 1 + date_img.size[0]) + 10 + after_offset
|
||||||
|
)
|
||||||
|
,32))
|
||||||
|
|
||||||
|
img.paste(flag_img,(x_offset, 0))
|
||||||
|
x_offset += flag_img.size[0] + 5
|
||||||
|
x_offset2 = x_offset + 1
|
||||||
|
img.paste(circle_img, (x_offset2, 15))
|
||||||
|
img.paste(indicator_img, (x_offset2 + circle_img.size[0] + 2, 11))
|
||||||
|
img.paste(imp_img, (x_offset2 + circle_img.size[0] + 2 + indicator_img.size[0] + 2, 15))
|
||||||
|
img.paste(title_img, (x_offset , 0))
|
||||||
|
x_offset += title_img.size[0] + 3
|
||||||
|
img.paste(country_img, (x_offset, 2))
|
||||||
|
x_offset += country_img.size[0]
|
||||||
|
|
||||||
|
img.paste(date_img, (x_offset2, 23))
|
||||||
|
try:
|
||||||
|
img.paste(clock_img, (x_offset2 + 3 + date_img.size[0], 24))
|
||||||
|
img.paste(period_img, (x_offset2 + 3 + date_img.size[0] + 2 + clock_img.size[0], 23))
|
||||||
|
x_offset2 += max(circle_img.size[0] + 2 + indicator_img.size[0] + 2 + imp_img.size[0],
|
||||||
|
date_img.size[0] + clock_img.size[0] + 3 + 2 + period_img.size[0]) + 10
|
||||||
|
except:
|
||||||
|
x_offset2 += max(circle_img.size[0] + 2 + indicator_img.size[0] + 2 + imp_img.size[0], date_img.size[0]) + 10
|
||||||
|
|
||||||
|
try:
|
||||||
|
if event['forecast'] != None:
|
||||||
|
img.paste(fore_img, (x_offset2, 14))
|
||||||
|
img.paste(fore2_img, (x_offset2, 22))
|
||||||
|
x_offset2 += max(fore_img.size[0], fore2_img.size[0]) + 3
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
if event['previous'] != None:
|
||||||
|
img.paste(prev_img, (x_offset2, 14))
|
||||||
|
img.paste(prev2_img, (x_offset2, 22))
|
||||||
|
x_offset2 += max(prev_img.size[0], prev2_img.size[0]) + 3
|
||||||
|
img.paste(actual_img, (x_offset2, 14))
|
||||||
|
img.paste(actual2_img, (x_offset2, 22))
|
||||||
|
x_offset2 += max(actual_img.size[0], actual2_img.size[0]) + 3
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
image_list.append(img)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif len(econ_settings['events']) == 0:
|
||||||
|
time.sleep(0.1)
|
||||||
|
no_econ = self.textImage('No upcoming economic events today.', font, r = 255, g = 255, b = 255)
|
||||||
|
img = Image.new('RGB', (no_econ.size[0] + 15, 32))
|
||||||
|
img.paste(no_econ, (10, 10))
|
||||||
|
image_list.append(img)
|
||||||
|
|
||||||
|
return self.stitchImage(image_list)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def ip_viewer(self):
|
def ip_viewer(self):
|
||||||
|
|
||||||
font = ImageFont.load("./fonts/6x10.pil")
|
font = ImageFont.load("./fonts/6x10.pil")
|
||||||
@ -5970,6 +6096,9 @@ class StockTicker():
|
|||||||
elif msg == 'IPO': #ipo
|
elif msg == 'IPO': #ipo
|
||||||
self.scrollFunctionsAnimated(['ipo', 'ipo'],animation = 'traditional')
|
self.scrollFunctionsAnimated(['ipo', 'ipo'],animation = 'traditional')
|
||||||
|
|
||||||
|
elif msg == 'EC': #economic calendar
|
||||||
|
self.scrollFunctionsAnimated(['economic', 'economic'],animation = 'traditional')
|
||||||
|
|
||||||
elif msg == 'A': #everything
|
elif msg == 'A': #everything
|
||||||
|
|
||||||
#userSettings = ['display_gif', 'text', 'display_image', 'stocks', 'crypto', 'forex', 'today_weather', 'daily_weather', 'league_table', 'league_games', 'news'] # these wil be read from csv, just for demo
|
#userSettings = ['display_gif', 'text', 'display_image', 'stocks', 'crypto', 'forex', 'today_weather', 'daily_weather', 'league_table', 'league_games', 'news'] # these wil be read from csv, just for demo
|
||||||
|
Loading…
Reference in New Issue
Block a user