From dba799fde667ef37cba3a756e444e4e019bf3957 Mon Sep 17 00:00:00 2001 From: Neradoc Date: Sat, 5 Jun 2021 12:53:01 +0200 Subject: [PATCH] Don't add "..." to every label The actual length of the text was not tested in set_text, the mere existence of `maxlen` was enough to shorten the string, or add `"..."` if the string was shorter than `maxlen - 3`. --- adafruit_portalbase/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_portalbase/__init__.py b/adafruit_portalbase/__init__.py index 20b16c7..c74ef9e 100755 --- a/adafruit_portalbase/__init__.py +++ b/adafruit_portalbase/__init__.py @@ -224,9 +224,9 @@ def set_text(self, val, index=0): if not self._text: self.add_text() string = str(val) - if self._text[index]["maxlen"]: + if self._text[index]["maxlen"] and len(string) > self._text[index]["maxlen"]: + # too long! shorten it if len(string) >= 3: - # too long! shorten it string = string[: self._text[index]["maxlen"] - 3] + "..." else: string = string[: self._text[index]["maxlen"]]