Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show a better message when exceeding max_glpyhs / initial text length #11

Closed
caternuson opened this issue May 23, 2019 · 8 comments
Closed
Labels
enhancement New feature or request

Comments

@caternuson
Copy link
Contributor

Maybe I'm incorrectly assuming the mutability of a Label? You can reassign the text, but if it is longer than the original text, then you exceed a Group limit.

Adafruit CircuitPython 4.0.0 on 2019-05-20; Adafruit PyPortal with samd51j20
>>> import terminalio
>>> from adafruit_display_text import label
>>> label = label.Label(terminalio.FONT, text="123456789")
>>> label.text = "1"
>>> label.text = "1234"
>>> label.text = "1234567"
>>> label.text = "123456789"
>>> label.text = "1234567890"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "adafruit_display_text/label.py", line 174, in text
  File "adafruit_display_text/label.py", line 119, in _update_text
RuntimeError: Group full
>>>
@iraytrace
Copy link

Given the nature of the Label, I would suggest this should either truncate the input text in the property setter method, or otherwise have a more graceful recovery.

@anecdata
Copy link
Member

anecdata commented Jun 3, 2019

I believe this behavior is currently as-designed. Label needs the maximum number of characters, or pixel width using the bounding box based on the current font. Enlarging the allocation, auto-truncation option, even a scrolling text option would be great. This gets tricky with multi-line text though.

I often use dynamic label text, so currently have to pre-calculate the width of the new text and create a replacement Label rather than just changing the text of an existing Label.

@makermelissa
Copy link
Contributor

If you pass in max_glyphs=30 or whatever number is your largest size, then it will handle this correctly. If not specified, it assumes the length of the default text is the max_glyphs. I believe this issue is more about having it degrade with a better message since "Group full" is a little misleading.

@dhalbert
Copy link
Contributor

I just encountered this too. I'd suggest either it just truncates or we catch the "Group full" exception and throw with a more meaningful exception message like "Text too long" or "Text exceeds max_glyphs".

@caternuson
Copy link
Contributor Author

Agree with above two comments - this issue is just a suggestion for better fail behavior. And once implemented, update the displayio guide.

Would truncating be the more user friendly option?

@kevinjwalters
Copy link

I just got confused with this too. I agree with @dhalbert and @jepler in Discord, a re-throw with a clearer exception would be a good thing.

@jepler jepler changed the title Group full when assigning longer text Show a better message when exceeding max_glpyhs / initial text length Mar 1, 2020
@kattni kattni added the enhancement New feature or request label May 4, 2020
@kevinjwalters
Copy link

kevinjwalters commented Jun 26, 2020

max_glyphs is also problematic as this is not documented in enough detail for the user to know that this needs to be maximum(all possible text lengths) + 1 - note the + 1.

The raise RuntimeError("Please provide a max size, or initial text") in the code doesn't really help here either as it mentions a max size.

Added later: I've just realised this is due to a fairly recent change in fb0cfee as I had a look into a feedback report for https://learn.adafruit.com/clue-sensor-plotter-circuitpython being broken. I put a simple example in Adafruit Forums: label.Label max_glyphs behaviour has changed
. This was fixed by 5fe2117

@caternuson
Copy link
Contributor Author

Closing this for now. Looks like it was nominally fixed with #48.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants