Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8609

Troubleshooting • Re: TypeError, Non-iterable int Object..... Reddit Quotes

$
0
0
it sounds like "font.getbbox(text)" didn't return an array
Yep, PoC -

Code:

x = (1, 2, 3)text_width, = x[2]print(text_width)

Code:

pi@Pi3B:/tmp $ python3 test.pyTraceback (most recent call last):  File "test.py", line 2, in <module>    text_width, = x[2]TypeError: cannot unpack non-iterable int object
At least we can presume the OP is running it with Python 3 as Python 2 gives a different error message.

It seems 'font.getbbox(text)' should be returning a one item list or tuple. PoC -

Code:

x = (1, 2, (3,))text_width, = x[2]print(text_width)
So I would guess 'font.getbbox(text)' isn't working or it can't handle whatever the 'text' was.

Statistics: Posted by hippy — Wed Jan 31, 2024 12:45 pm



Viewing all articles
Browse latest Browse all 8609

Trending Articles