From ba2eeeec81dd545d3a819a09e13afb78068b2f65 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Sat, 17 Jan 2026 19:47:13 +0100 Subject: [PATCH] grouping (tausender-punkt). color. --- scenes/bitcoin.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/scenes/bitcoin.py b/scenes/bitcoin.py index 3105382..1c9aa96 100644 --- a/scenes/bitcoin.py +++ b/scenes/bitcoin.py @@ -3,6 +3,8 @@ import time from PIL import Image, ImageDraw import lib.display +import locale +locale.setlocale(locale.LC_ALL, "de_DE.UTF-8") # Replace with your free Finnhub API key API_KEY = "d3t8099r01qigeg1s7cgd3t8099r01qigeg1s7d0" @@ -20,29 +22,31 @@ def start(stop_event, args): trend = None image_buffer = lib.display.matrix.buffer() draw = ImageDraw.Draw(image_buffer) - #symbol = '⏶' + symbol = '-' + color = (255,255,255) + while not stop_event.is_set(): # All to black draw.rectangle( ((0,0),(lib.display.matrix.width-1,lib.display.matrix.height-1)), fill=(0,0,0) ) price = get_bitcoin_price() + price_str = locale.format_string("%d", price, grouping=True) # Trend berechnen if last_price: if price > last_price: trend = 1 - #symbol = "🡅" + symbol = "▴" + color = (0, 255, 0) elif price < last_price: trend = -1 - #symbol = "🡇" + symbol = "▾" + color = (255, 0, 0) - #display.triangle(draw, 0, 0, trend, width=16, height=32) - #print(symbol) + text = f"{symbol} BTC: {price_str}€" + #text = f"BTC: {price:.0f}€" - #text = f"{symbol} BTC: {price:.0f}€" - text = f"BTC: {price:.0f}€" - - draw.text((20, 0), text, fill=(255, 255, 255), font=lib.display.matrix.large_font) + draw.text((10, 0), text, fill=color, font=lib.display.matrix.large_font) lib.display.matrix.show(image_buffer) @@ -51,6 +55,6 @@ def start(stop_event, args): for i in range(1,10): if stop_event.is_set(): return - + time.sleep(1)