#Word wrapping on the PyPortal (solved)

1 messages · Page 1 of 1 (latest)

nova turtle
#

I am trying to understand word wrapping by following the guide here: https://learn.adafruit.com/making-a-pyportal-user-interface-displayio/overview

In the project code (https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/81345f559067451fc60c7a8e55e16d40d0663bdb/PyPortal_User_Interface/code.py#L116-L118) , the for loop builds two strings. I cannot figure out why one string (new_text) is concatted new line first while the second string (test) is concatted new line last? Why are the leading/trailing new line characters not stripped before doing size calculations?

Adafruit Learning System

Do more stuff with your PyPortal by making a multi-panel user interface.

GitHub

Programs and scripts to display "inline" in Adafruit Learning System guides - Adafruit_Learning_System_Guides/code.py at 81345f559067451fc60c7a8e55e16d40d0663bdb · adafruit/Adafru...

opal light
#

the test variable is probably to work around a bug in Label where empty lines would not be counted when calculating the y position of a label

#

so that this:

M
M
M

would be correctly placed, but not this:

M

M
#

so it creates the "test" version to get the correct position and transfers it to the real label

#

that bug should be fixed now though, but the fix is not be in the frozen library on the board, you would have to place the updated one in the root of CIRCUITPY

#

hmmmm I'll check with that code to see if it's really fixed anyway

nova turtle
#

Do you think that could be what the comments are referring to as "odd behavior?" (a few lines down from the highlighted code above)

opal light
#

yeah

nova turtle
#

Ok I guess I will leave it in my code then until I verify that the issue has been fixed. Thanks!

#

Word wrapping on the PyPortal (solved)

opal light
#

I'm not sure I understand the logic of the label placement in that code. It seems like it's trying to center the text while keeping it below the tabs buttons, but adds an empty line to create an offset