custom imgs prof

This commit is contained in:
Justin 2023-01-09 12:46:39 +08:00 committed by GitHub
parent 94e0380462
commit 27336d73f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -74,7 +74,7 @@ class StockTicker():
'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,
'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'), 'Custom Messages Prof': self.getUserMessagesProfessional}
'Sports (Past Games) Prof': lambda : self.getLeagueProfessional('NBA', 'past'), 'Custom Messages Prof': self.getUserMessagesProfessional, 'Custom Images Prof': self.getUserImagesProfessional}
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',
@ -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',
'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',
'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'}
'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', 'Custom Images Prof': 'csv/image_settings.json'}
def openImage(self, image_file):
@ -3404,6 +3404,59 @@ class StockTicker():
return imgs
def getUserImagesProfessional(self):
f = open('csv/image_settings.json', 'r')
all_settings = json.load(f)
f.close()
if all_settings['title']:
title_img = self.openImage('feature_titles/small_feature_titles/images.png')
image_list = [title_img]
else:
image_list = []
blank = Image.new('RGB', (0, 16))
for i,image in enumerate(all_settings['images']):
if (i == len(all_settings['images'])-1):
try:
user_image = self.openImage(os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'user_uploads'), image))
user_image.thumbnail((99999, 16))
#user_image.convert('RGB')
img = Image.new('RGB', (user_image.size[0] + 5, 32))
img.paste(user_image, (0,0))
image_list.append(img)
image_list.append(blank)
except Exception as e:
pass
else:
try:
user_image = self.openImage(os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'user_uploads'), image))
user_image.thumbnail((99999, 16))
#user_image.convert('RGB')
img = Image.new('RGB', (user_image.size[0] + 130, 32))
img.paste(user_image, (0,0))
image_list.append(img)
image_list.append(blank)
except Exception as e:
pass
return self.stitchImage(image_list)
def getUserGIFs(self):
f = open('csv/GIF_settings.json', 'r')
all_settings = json.load(f)
@ -3493,6 +3546,7 @@ class StockTicker():
sports_upcoming = self.getLeagueProfessional()
sports_past = self.getLeagueProfessional()
messages = self.getUserMessagesProfessional()
images = self.getUserImagesProfessional()
x_offset = 0
news.paste(weather, (x_offset, 16))
@ -3517,6 +3571,8 @@ class StockTicker():
x_offset += sports_past.size[0]
news.paste(messages, (x_offset, 16))
x_offset += messages.size[0]
news.paste(images, (x_offset, 16))
x_offset += images.size[0]
self.double_buffer = self.matrix.CreateFrameCanvas()
while True:
kill = stock_ticker.scrollImage(news, offset_x = 128)