From a47c8a8d536f4129d43f597351d5b66b9e685958 Mon Sep 17 00:00:00 2001 From: Justin Date: Thu, 14 Sep 2023 15:21:01 +0800 Subject: [PATCH] prof added display_names --- stockTicker.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/stockTicker.py b/stockTicker.py index 2d5aad8..08270cb 100755 --- a/stockTicker.py +++ b/stockTicker.py @@ -1025,6 +1025,25 @@ class StockTicker(): newWidth = max(w2 + text_width_change, text_width_current) +15 img = img.crop((0,0,newWidth,32)) + elif 'display_name' in TICKER: + TICKER = TICKER.replace('display_name','') + w1, text_height = self.get_text_dimensions(TICKER, font) + w2, text_height = self.get_text_dimensions(CURRENT, font) + text_width_current = max(w1,w2) + + img = Image.new('RGB', (text_width_current +100 , 32)) + d = ImageDraw.Draw(img) + + d.text((4, 0), TICKER, fill=(255, 255, 255), font=font) + d.text((4, 8), CURRENT, fill=self.greenORred, font=font) + + img.paste(ARROW, ((w2 + 7),10)) + d.text(((w2+18), 8), CHANGE, fill=self.greenORred, font=font) + + text_width_change, text_height = self.get_text_dimensions(CHANGE, font) + newWidth = max(w2 + 15 + text_width_change, text_width_current) +15 + img = img.crop((0,0,newWidth,32)) + elif 'Sector' in CHANGE: w1, text_height = self.get_text_dimensions(TICKER, font) w2, text_height = self.get_text_dimensions(CURRENT, font) @@ -1373,7 +1392,7 @@ class StockTicker(): if names: try: - ticker = coin_info[cb]['name'].upper() + ticker = coin_info[cb]['name'].upper() + 'display_name' midFrame = self.textToImageProf(ticker, current, change, arrow, font=ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT except: ticker, base = cb.split(',') @@ -2436,7 +2455,7 @@ class StockTicker(): change = float(info['change'])#TEXT if names: try: - ticker = info['name'].upper() #TEXT + ticker = info['name'].upper() + 'display_name' #TEXT except: ticker = symbol else: @@ -7013,7 +7032,7 @@ class StockTicker(): change = float(info['change'])#TEXT if names: try: - ticker = info['name'].upper() #TEXT + ticker = info['name'].upper() + 'display_name' #TEXT except: ticker = symbol else: @@ -7094,7 +7113,7 @@ class StockTicker(): change = float(info['change'])#TEXT if names: try: - ticker = info['name'].upper() #TEXT + ticker = info['name'].upper() + 'display_name' #TEXT except: ticker = symbol else: @@ -7179,7 +7198,7 @@ class StockTicker(): change = float(info['change'])#TEXT if names: try: - ticker = info['name'].upper() #TEXT + ticker = info['name'].upper() + 'display_name' #TEXT except: ticker = symbol else: