- 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
28 lines
968 B
Python
28 lines
968 B
Python
"""Demo-Plugin: konfigurierbarer Text."""
|
|
import os, sys
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
|
from plugins.base import Widget
|
|
from palette import fill_for, measure, fit_font, centered_text
|
|
|
|
|
|
class Widget(Widget):
|
|
name = "hello"
|
|
label = "Hello / Demo"
|
|
description = "Zeigt einen konfigurierbaren Text. Responsiv."
|
|
category = "general"
|
|
|
|
config_schema = [
|
|
{"key": "text", "label": "Text", "type": "string", "default": "Hello!"},
|
|
{"key": "color", "label": "Farbe", "type": "select",
|
|
"choices": ["fg", "info", "ok", "warn", "alert", "accent"], "default": "fg"},
|
|
]
|
|
default_config = {"text": "Hello!", "color": "fg"}
|
|
|
|
def fetch(self):
|
|
return {}
|
|
|
|
def render(self, draw, fonts, x, y, w, h):
|
|
text = self.cfg("text", "Hello!")
|
|
font = fit_font(draw, text, fonts, w - 16, h - 16)
|
|
centered_text(draw, text, x, y, w, h, font, fill_for(self.cfg("color", "fg")))
|