fixed trailing zeros for crypto

This commit is contained in:
Justin 2023-05-03 12:42:05 +08:00 committed by GitHub
parent 2534f18495
commit 3d7da19b3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1025,7 +1025,16 @@ class StockTicker():
arrow, change = self.getArrow(point_change)
percent_change = '%.2f' % abs(percent_change) + '%'
num3 = point_changefinal.split('.')
if len(num3[1]) <= 1:
point_change = '%.2f' % float(point_changefinal)
else:
point_change = str(point_changefinal)
num2 = current_final.split('.')
if len(num2[1]) <= 1:
current = '%.2f' % float(current_final)
else:
current = str(current_final)
if not all_crypto_settings['percent']:
@ -1188,10 +1197,19 @@ class StockTicker():
if all_crypto_settings["percent"]:
# convert percent to points
change = '%.2f' % abs(float(coin_info[cb]['percent_change'])) + '%'
else:
num3 = changefinal.split('.')
if len(num3[1]) <= 1:
change = '%.2f' % float(changefinal)
else:
change = str(changefinal)
num2 = current_final.split('.')
if len(num2[1]) <= 1:
current = '%.2f' % float(current_final)
else:
current = str(current_final)
midFrame = self.textToImageProf(ticker + '(' + base + ')', current, change, arrow, font=ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT
if all_crypto_settings['logos']:
try: