fixed spacing issues with e-mini items in prof display

This commit is contained in:
Justin 2023-07-20 15:29:45 +08:00 committed by GitHub
parent e4a17ec354
commit bfb4feae18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -947,26 +947,46 @@ class StockTicker():
img = img.crop((0,0,max(w1, w2) + 20,32))
return img
def textToImageProf(self, TICKER, CURRENT, CHANGE, ARROW, font):
text_width_current, text_height = self.get_text_dimensions(CURRENT, font)
if 'E-MINI' in TICKER:
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)
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)
d.text((4, 0), TICKER, fill=(255, 255, 255), font=font)
d.text((4, 8), CURRENT, fill=self.greenORred, font=font)
img.paste(ARROW, ((text_width_current + 7),10))
d.text(((text_width_current+18), 8), CHANGE, 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)
text_width_change, text_height = self.get_text_dimensions(CHANGE, font)
newWidth = max(w2 + text_width_change, text_width_current) +15
img = img.crop((0,0,newWidth,32))
newWidth = text_width_current + text_width_change +30
else:
text_width_current, text_height = self.get_text_dimensions(CURRENT, font)
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, ((text_width_current + 7),10))
d.text(((text_width_current+18), 8), CHANGE, fill=self.greenORred, font=font)
text_width_change, text_height = self.get_text_dimensions(CHANGE, font)
newWidth = text_width_current + text_width_change +30
img = img.crop((0,0,newWidth,32))
img = img.crop((0,0,newWidth,32))
return img
#Stitch the logo & prices picture into one image
def stitchImage(self, image_list):
widths, heights = zip(*(i.size for i in image_list))