custom messages prof
This commit is contained in:
parent
6904face89
commit
85af94a034
@ -74,7 +74,7 @@ class StockTicker():
|
|||||||
'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,
|
||||||
'Daily Forecast Prof':self.getDailyWeatherProfessional, 'Sports (Team Stats) Prof':lambda : self.getLeagueTableProfessional('NHL'), 'Sports (Upcoming Games) Prof': lambda : self.getLeagueProfessional('NHL', 'future'),
|
'Daily Forecast Prof':self.getDailyWeatherProfessional, 'Sports (Team Stats) Prof':lambda : self.getLeagueTableProfessional('NHL'), 'Sports (Upcoming Games) Prof': lambda : self.getLeagueProfessional('NHL', 'future'),
|
||||||
'Sports (Past Games) Prof': lambda : self.getLeagueProfessional('NBA', 'past')}
|
'Sports (Past Games) Prof': lambda : self.getLeagueProfessional('NBA', 'past'), 'Custom Messages Prof': self.getUserMessagesProfessional}
|
||||||
|
|
||||||
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',
|
||||||
@ -83,7 +83,7 @@ class StockTicker():
|
|||||||
'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',
|
||||||
'Current Weather Prof': 'csv/current_weather.json', 'News Prof':'csv/news_settings.json', 'Commodities Prof':'csv/commodities_settings.json', 'Indices Prof': 'csv/indices_settings.json',
|
'Current Weather Prof': 'csv/current_weather.json', 'News Prof':'csv/news_settings.json', 'Commodities Prof':'csv/commodities_settings.json', 'Indices Prof': 'csv/indices_settings.json',
|
||||||
'Daily Forecast Prof':'csv/daily_weather.json', 'Sports (Team Stats) Prof': 'csv/league_tables.json', 'Sports (Upcoming Games) Prof': 'csv/upcoming_games.json', 'Sports (Past Games) Prof': 'csv/past_games.json'}
|
'Daily Forecast Prof':'csv/daily_weather.json', 'Sports (Team Stats) Prof': 'csv/league_tables.json', 'Sports (Upcoming Games) Prof': 'csv/upcoming_games.json', 'Sports (Past Games) Prof': 'csv/past_games.json', 'Custom Messages Prof': 'csv/message_settings.json'}
|
||||||
|
|
||||||
|
|
||||||
def openImage(self, image_file):
|
def openImage(self, image_file):
|
||||||
@ -749,6 +749,71 @@ class StockTicker():
|
|||||||
|
|
||||||
return imgs
|
return imgs
|
||||||
|
|
||||||
|
|
||||||
|
def getUserMessagesProfessional(self):
|
||||||
|
|
||||||
|
f = open('csv/message_settings.json', 'r')
|
||||||
|
all_settings = json.load(f)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
if all_settings['title']:
|
||||||
|
title_img = self.openImage('feature_titles/small_feature_titles/message.png')
|
||||||
|
image_list = [title_img]
|
||||||
|
else:
|
||||||
|
image_list = []
|
||||||
|
|
||||||
|
colours = {'Black':(0,0,0),
|
||||||
|
'White':(255,255,255),
|
||||||
|
'Red':(255,0,0),
|
||||||
|
'Green':(0,255,0),
|
||||||
|
'Dark Green':(0,100,0),
|
||||||
|
'Blue':(0,0,255),
|
||||||
|
'Purple':(145,0,255),
|
||||||
|
'Pink':(255,0,255),
|
||||||
|
'Yellow':(255,255,0),
|
||||||
|
'Orange':(255,130,0),
|
||||||
|
'Gold':(255,190,0),
|
||||||
|
'Gray':(100,100,100),
|
||||||
|
'Cyan':(0,255,255)}
|
||||||
|
|
||||||
|
blank = Image.new('RGB', (0, 16))
|
||||||
|
|
||||||
|
for i, message in enumerate(all_settings['messages']):
|
||||||
|
if (i == len(all_settings['messages'])-1):
|
||||||
|
font = ImageFont.load("./fonts/6x13.pil")
|
||||||
|
location = (5, 2)
|
||||||
|
|
||||||
|
|
||||||
|
r,g,b = colours[message['text_colour']]
|
||||||
|
|
||||||
|
background = colours[message['background_colour']]
|
||||||
|
msg_img = self.textImage(message['text'], font, int(r), int(g), int(b), True, w_buff = 11, background = background, location = location)
|
||||||
|
|
||||||
|
img = Image.new('RGB', (msg_img.size[0] + 5, 32))
|
||||||
|
img.paste(msg_img, (0,0))
|
||||||
|
|
||||||
|
image_list.append(img)
|
||||||
|
image_list.append(blank)
|
||||||
|
|
||||||
|
else:
|
||||||
|
font = ImageFont.load("./fonts/6x13.pil")
|
||||||
|
location = (5, 2)
|
||||||
|
|
||||||
|
|
||||||
|
r,g,b = colours[message['text_colour']]
|
||||||
|
|
||||||
|
background = colours[message['background_colour']]
|
||||||
|
msg_img = self.textImage(message['text'], font, int(r), int(g), int(b), True, w_buff = 11, background = background, location = location)
|
||||||
|
|
||||||
|
img = Image.new('RGB', (msg_img.size[0] + 130, 32))
|
||||||
|
img.paste(msg_img, (0,0))
|
||||||
|
|
||||||
|
image_list.append(img)
|
||||||
|
image_list.append(blank)
|
||||||
|
|
||||||
|
return self.stitchImage(image_list)
|
||||||
|
|
||||||
|
|
||||||
def displayGIF(self, gif, delay = 0.5, repeat = True):
|
def displayGIF(self, gif, delay = 0.5, repeat = True):
|
||||||
# To iterate through the entire gif
|
# To iterate through the entire gif
|
||||||
i = 0
|
i = 0
|
||||||
@ -3427,6 +3492,7 @@ class StockTicker():
|
|||||||
sports_stats = self.getLeagueTableProfessional()
|
sports_stats = self.getLeagueTableProfessional()
|
||||||
sports_upcoming = self.getLeagueProfessional()
|
sports_upcoming = self.getLeagueProfessional()
|
||||||
sports_past = self.getLeagueProfessional()
|
sports_past = self.getLeagueProfessional()
|
||||||
|
messages = self.getUserMessagesProfessional()
|
||||||
|
|
||||||
x_offset = 0
|
x_offset = 0
|
||||||
news.paste(weather, (x_offset, 16))
|
news.paste(weather, (x_offset, 16))
|
||||||
@ -3449,6 +3515,8 @@ class StockTicker():
|
|||||||
x_offset += sports_upcoming.size[0]
|
x_offset += sports_upcoming.size[0]
|
||||||
news.paste(sports_past, (x_offset, 16))
|
news.paste(sports_past, (x_offset, 16))
|
||||||
x_offset += sports_past.size[0]
|
x_offset += sports_past.size[0]
|
||||||
|
news.paste(messages, (x_offset, 16))
|
||||||
|
x_offset += messages.size[0]
|
||||||
self.double_buffer = self.matrix.CreateFrameCanvas()
|
self.double_buffer = self.matrix.CreateFrameCanvas()
|
||||||
while True:
|
while True:
|
||||||
kill = stock_ticker.scrollImage(news, offset_x = 128)
|
kill = stock_ticker.scrollImage(news, offset_x = 128)
|
||||||
|
Loading…
Reference in New Issue
Block a user