From 92266a783aad482108cd9051827e1e8232eadb4c Mon Sep 17 00:00:00 2001 From: Ben Lebherz Date: Wed, 13 Nov 2019 21:11:21 +0100 Subject: [PATCH] make label to value space configurable to better fit small fonts --- pwnagotchi/ui/components.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pwnagotchi/ui/components.py b/pwnagotchi/ui/components.py index 87b0576..1bc7ae9 100644 --- a/pwnagotchi/ui/components.py +++ b/pwnagotchi/ui/components.py @@ -58,12 +58,13 @@ class Text(Widget): class LabeledValue(Widget): - def __init__(self, label, value="", position=(0, 0), label_font=None, text_font=None, color=0): + def __init__(self, label, value="", position=(0, 0), label_font=None, text_font=None, color=0, label_spacing=5): super().__init__(position, color) self.label = label self.value = value self.label_font = label_font self.text_font = text_font + self.label_spacing = label_spacing def draw(self, canvas, drawer): if self.label is None: @@ -71,4 +72,4 @@ class LabeledValue(Widget): else: pos = self.xy drawer.text(pos, self.label, font=self.label_font, fill=self.color) - drawer.text((pos[0] + 5 + 5 * len(self.label), pos[1]), self.value, font=self.text_font, fill=self.color) + drawer.text((pos[0] + self.label_spacing + 5 * len(self.label), pos[1]), self.value, font=self.text_font, fill=self.color)