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`.
This commit is contained in:
Neradoc 2021-06-05 12:53:01 +02:00 committed by GitHub
parent 9d180931ef
commit dba799fde6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -224,9 +224,9 @@ class PortalBase:
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"]]