- dashboard.py: plugin-based renderer with 4x4 grid layout - admin.py: web UI with layout editor + plugin configs - layout.py: pack algorithm, item placement, grid system - plugins/: clock, weather, system, spotify, strava, gmail, minimax, hello - network_watchdog.py: WiFi AP/client mode management - waveshare_epd_init.py: vendor driver stub
41 lines
2.1 KiB
Python
41 lines
2.1 KiB
Python
"""Demo: Progress-Bars mit Gradient und konfigurierbaren Schwellen."""
|
|
import sys; sys.path.insert(0, ".")
|
|
from PIL import Image, ImageDraw, ImageFont
|
|
from palette import hbar, parse_thresholds, FG, OK, WARN, ALERT, ORANGE, BLUE, GREEN, RED, YELLOW
|
|
|
|
def font(s): return ImageFont.truetype("fnt/Aldrich-Regular.ttc", s)
|
|
fonts = {str(s): font(s) for s in [16, 20, 24]}
|
|
|
|
img = Image.new("RGB", (800, 600), (255,255,255))
|
|
draw = ImageDraw.Draw(img)
|
|
|
|
# Title
|
|
draw.text((20, 10), "Gradient Bars - 3-stufig default (50/80/95)", font=font(20), fill=FG)
|
|
|
|
# Row 1: gradient on (default thresholds)
|
|
draw.text((20, 50), "Gradient AN, Thresholds 50/80/95", font=font(16), fill=FG)
|
|
hbar(draw, 20, 80, 760, 30, 25, thresholds=parse_thresholds("ok@50,warn@80,alert@95"), gradient=True)
|
|
draw.text((20, 115), "25% (ok)", font=font(16), fill=FG)
|
|
hbar(draw, 20, 140, 760, 30, 65, thresholds=parse_thresholds("ok@50,warn@80,alert@95"), gradient=True)
|
|
draw.text((20, 175), "65% (warn)", font=font(16), fill=FG)
|
|
hbar(draw, 20, 200, 760, 30, 90, thresholds=parse_thresholds("ok@50,warn@80,alert@95"), gradient=True)
|
|
draw.text((20, 235), "90% (alert)", font=font(16), fill=FG)
|
|
|
|
# Row 2: gradient off
|
|
draw.text((20, 280), "Gradient AUS (einfarbig in aktueller Schwelle)", font=font(20), fill=FG)
|
|
hbar(draw, 20, 310, 760, 30, 25, thresholds=parse_thresholds("ok@50,warn@80,alert@95"), gradient=False)
|
|
draw.text((20, 345), "25% einfarbig green", font=font(16), fill=FG)
|
|
hbar(draw, 20, 370, 760, 30, 65, thresholds=parse_thresholds("ok@50,warn@80,alert@95"), gradient=False)
|
|
draw.text((20, 405), "65% einfarbig yellow", font=font(16), fill=FG)
|
|
hbar(draw, 20, 430, 760, 30, 90, thresholds=parse_thresholds("ok@50,warn@80,alert@95"), gradient=False)
|
|
draw.text((20, 465), "90% einfarbig red", font=font(16), fill=FG)
|
|
|
|
# Row 3: custom thresholds (mehr Stufen)
|
|
draw.text((20, 510), "Custom: 4 Stufen 30/60/80/95, custom colors", font=font(20), fill=FG)
|
|
spec = [(30, GREEN), (60, YELLOW), (80, ORANGE), (95, RED)]
|
|
hbar(draw, 20, 545, 760, 30, 50, thresholds=spec, gradient=True)
|
|
draw.text((20, 580), "50% → yellow segment", font=font(16), fill=FG)
|
|
|
|
img.save("/tmp/gradient_demo.png")
|
|
print("saved /tmp/gradient_demo.png")
|