Forum Archive

ui.measure_string always giving (0.0, 0.0)

JadedTuna

Any ideas why?
My code is:

import ui

print ui.measure_string("Doesn't work")
brumm

'Return the dimensions (width, height) of a string if it was drawn with draw_string().'
If you like take my example and put your line into the draw method. (73.70399475097656, 14.315999984741211)

omz

Sorry, this is a bug, ui.measure_string currently only works when called on the main thread, in a drawing context (e.g. when overriding a View's draw method).

JadedTuna

@omz, now I understand. Waiting for the new Pythonista with fixes :D

mikael

+1 for fixing this bug