Skip to content

Width property not working in some cases #155

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

Closed
FoamyGuy opened this issue Jul 24, 2021 · 4 comments
Closed

Width property not working in some cases #155

FoamyGuy opened this issue Jul 24, 2021 · 4 comments

Comments

@FoamyGuy
Copy link
Contributor

Ref: adafruit/Adafruit_CircuitPython_MacroPad#10

Width and height properties do exist in LabelBase. I'm not sure why it's raising AttributeNotFound in this context.

I am looking into it further and working on a fix now.

@FoamyGuy
Copy link
Contributor Author

I tested this minimal example:

import board
import terminalio
from adafruit_display_text import bitmap_label

text = "Hello world"
text_area = bitmap_label.Label(terminalio.FONT, text=text)
text_area.x = 10
text_area.y = 10
board.DISPLAY.show(text_area)

print(text_area.width)
while True:
    pass

It does print the width and does not raise an AttributeError. So this is somehow tied into the usage inside of grid_layout. Trying that out next to see if I can find a minimal reproducer.

@lesamouraipourpre
Copy link
Contributor

The way I did the width and height properties on LabelBase, they are read-only. That might be the source of the error.

Investigating further as well but I don't have a MacroPad, so I'll have to knock up a similar but different test.

@FoamyGuy
Copy link
Contributor Author

The way I did the width and height properties on LabelBase, they are read-only. That might be the source of the error.

Investigating further as well but I don't have a MacroPad, so I'll have to knock up a similar but different test.

Yep, I think you are right. GridLayout is trying to set them and that is causing the error. In the old version they existed as class variables (unsure if proper term) which allowed them to be set even though it did not have a real effect.

I think the best solution for now will be to catch the error in GridLayout. I'm going to try that out on the stream today.

@FoamyGuy
Copy link
Contributor Author

It turned out this needed to be fixed inside the DisplayIO_Layout library. The PR to resolve this is here: adafruit/Adafruit_CircuitPython_DisplayIO_Layout#42

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

No branches or pull requests

2 participants