Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # measure_text_demo.py
- import appuifw, e32, graphics
- import math
- def draw(rect):
- try: canvas.blit(img)
- except: pass
- def quit():
- script_lock.signal()
- canvas = appuifw.Canvas(redraw_callback=draw)
- appuifw.app.directional_pad=False
- appuifw.app.orientation='portrait'
- appuifw.app.screen='large'
- appuifw.app.body=canvas
- w,h = canvas.size
- img=graphics.Image.new((w,h))
- msg="Thank You Very Much!"
- bounds, to_right, count = img.measure_text(unicode(msg, 'utf-8'))
- print
- print msg
- print bounds
- print to_right
- print count # similar to len()
- img.text((bounds[0],bounds[1]*-1), unicode(msg, 'utf-8'), fill=(255,0,0))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement