Wrap Text To Fit Canvas Screen
Join the DZone community and get the full member experience.Join For Free
Pys60 provide you with 3 types for app.body - Text - ListBox - Canvas Sometimes you want some text and image together, you need to use canvas. However, there's no way to calculate the length of text and wrap them properly. Simo's dashboard provide a solution to this using his akntextutils C++ extension.
from akntextutils import wrap_text_to_array # long_str is a long string to be wrapped lines = wrap_text_to_array(long_str, 'dense', 176) x, y = 2, 0 for line in lines: y += 14 canvas.text((x, y), line, font='dense')
Opinions expressed by DZone contributors are their own.