Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Korakot Chaovavanich http://korakot.stumbleupon.com

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Wrap text to fit canvas screen

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.
   1  
   2  from akntextutils import wrap_text_to_array
   3  
   4  # long_str is a long string to be wrapped
   5  lines = wrap_text_to_array(long_str, 'dense', 176)
   6  
   7  x, y = 2, 0
   8  for line in lines:
   9     y += 14
  10     canvas.text((x, y), line, font='dense')
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS