"""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")))