Skip to content

Commit

Permalink
make label to value space configurable to better fit small fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
benleb committed Nov 13, 2019
1 parent 1ff14c0 commit 92266a7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pwnagotchi/ui/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,18 @@ def draw(self, canvas, drawer):


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:
drawer.text(self.xy, self.value, font=self.label_font, fill=self.color)
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)

0 comments on commit 92266a7

Please sign in to comment.