added display name

This commit is contained in:
Justin 2023-09-13 22:21:50 +08:00 committed by GitHub
parent a8b079b02c
commit 9a357655f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1120,8 +1120,6 @@ class StockTicker():
current_final = '{0:.10f}'.format(current).rstrip("0")
percent_change = float(coin_info[cb]["percent_change"])
arrow, change = self.getArrow(point_change)
percent_change = '%.2f' % abs(percent_change) + '%'
@ -1142,12 +1140,16 @@ class StockTicker():
if not all_crypto_settings['point']:
point_change = False
if names:
ticker = coin_info[cb]['name']
midFrame = self.textToImage(ticker, current, arrow, percent_change, point_change) #IMAGE THE TEXT
else:
midFrame = self.textToImage(ticker + '(' + base + ')', current, arrow, percent_change, point_change) #IMAGE THE TEXT
if all_crypto_settings['logos']:
try:
ticker, base = cb.split(',')
logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'crypto')
logo = self.openImage(os.path.join(logos_path, ticker + '.png'))
stitchedStock = self.stitchImage([logo,midFrame])
except Exception as e:
@ -2072,14 +2074,12 @@ class StockTicker():
f = open('csv/stocks_settings.json', 'r')
all_stocks_settings = json.load(f)
f.close()
if all_stocks_settings['title']:
title_img = self.openImage('feature_titles/stocks.png')
image_list = [title_img]
image_list.append(self.blank)
else:
image_list = []
if all_stocks_settings['chart']:
try:
f = open('csv/portfolio_settings.json', 'r')
@ -2087,7 +2087,6 @@ class StockTicker():
f.close()
except:
pass
try:
if all_stocks_settings['prepost']:
try:
@ -2098,7 +2097,6 @@ class StockTicker():
pass
except:
pass
try:
if all_stocks_settings['display_name']:
names = True
@ -2108,19 +2106,20 @@ class StockTicker():
names = False
pass
stock_info = all_stocks_settings['symbols']
symbols = list(stock_info.keys())
timenow = datetime.now(ny_zone).replace(tzinfo=None).strftime("%H:%M:%S")
weekday = datetime.now(ny_zone).replace(tzinfo=None).weekday()
for i, symbol in enumerate(symbols):
try:
info = stock_info[symbol]
change = float(info['change']) #TEXT
ticker = symbol #TEXT
if names:
ticker = info['name'] #TEXT
else:
ticker = symbol
arrow, change = self.getArrow(change)
@ -2138,12 +2137,11 @@ class StockTicker():
if all_stocks_settings['logos']:
try:
ticker = symbol
logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'stocks')
logo = self.openImage(os.path.join(logos_path, ticker + '.png'))
stitchedStock = self.stitchImage([logo,midFrame])
except Exception as e:
stitchedStock = midFrame
else:
stitchedStock = midFrame
@ -2174,7 +2172,6 @@ class StockTicker():
pass
except:
pass
try:
if all_stocks_settings['prepost']:
font = ImageFont.load("./fonts/6x13.pil")
@ -2251,7 +2248,6 @@ class StockTicker():
except:
pass
try:
if all_stocks_settings['chart'] and (symbol in portfolio_settings): #IF USER INPUTTED PORTFOLIO SETTINGS, DISPLAY PORTFOLIO INFO
try:
@ -6753,7 +6749,10 @@ class StockTicker():
try:
info = active_info[symbol]
change = float(info['change']) #TEXT
ticker = symbol #TEXT
if names:
ticker = info['name'] #TEXT
else:
ticker = symbol
arrow, change = self.getArrow(change)
percent_change = '%.2f' % abs(float(info['percent_change'])) + '%'
point_change = '%.2f' % abs(change)
@ -6765,6 +6764,7 @@ class StockTicker():
midFrame = self.textToImage(ticker, current, arrow, percent_change, point_change) #IMAGE THE TEXT
if market_settings['logos']:
try:
ticker = symbol
logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'stocks')
logo = self.openImage(os.path.join(logos_path, ticker + '.png'))
stitchedStock = self.stitchImage([logo,midFrame])
@ -6818,7 +6818,10 @@ class StockTicker():
try:
info = gainers_info[symbol]
change = float(info['change']) #TEXT
ticker = symbol #TEXT
if names:
ticker = info['name'] #TEXT
else:
ticker = symbol
arrow, change = self.getArrow(change)
percent_change = '%.2f' % abs(float(info['percent_change'])) + '%'
point_change = '%.2f' % abs(change)
@ -6830,6 +6833,7 @@ class StockTicker():
midFrame = self.textToImage(ticker, current, arrow, percent_change, point_change) #IMAGE THE TEXT
if market_settings['logos']:
try:
ticker = symbol
logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'stocks')
logo = self.openImage(os.path.join(logos_path, ticker + '.png'))
stitchedStock = self.stitchImage([logo,midFrame])
@ -6883,6 +6887,9 @@ class StockTicker():
try:
info = losers_info[symbol]
change = float(info['change']) #TEXT
if names:
ticker = info['name']
else:
ticker = symbol #TEXT
arrow, change = self.getArrow(change)
percent_change = '%.2f' % abs(float(info['percent_change'])) + '%'
@ -6895,6 +6902,7 @@ class StockTicker():
midFrame = self.textToImage(ticker, current, arrow, percent_change, point_change) #IMAGE THE TEXT
if market_settings['logos']:
try:
ticker = symbol
logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'stocks')
logo = self.openImage(os.path.join(logos_path, ticker + '.png'))
stitchedStock = self.stitchImage([logo,midFrame])