Advertisement
here2share

# vertical_text_scroll.py

Jun 27th, 2016
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # vertical_text_scroll.py
  2.  
  3. import os,sys,time,math,random
  4. import appuifw,graphics,key_codes,e32,audio,sensor
  5. from appuifw import *
  6. from graphics import *
  7.  
  8. run=1
  9. def exit():global run; run=0
  10. app.exit_key_handler=exit
  11. app_lock=e32.Ao_lock()
  12.  
  13. def draw(rect):
  14.     try: canvas.blit(img)
  15.     except: pass
  16.  
  17. img=None
  18. appuifw.app.screen='large'
  19. appuifw.app.orientation='portrait'
  20. appuifw.app.directional_pad=False
  21. appuifw.app.body=canvas=Canvas(redraw_callback=draw)
  22. img=Image.new(canvas.size)
  23.  
  24. w, h=canvas.size
  25.  
  26. def up_event(event):
  27.     pass
  28. def dn_event(event):
  29.     pass
  30. canvas.bind(key_codes.EButton1Up, up_event, ((0,0), (w,h)))
  31. canvas.bind(key_codes.EButton1Down, dn_event, ((0,0), (w,h)))
  32.  
  33. def mv_event(event):
  34.     pass
  35. canvas.bind(key_codes.EDrag, mv_event, ((0,0), (w,h)))
  36.  
  37. img.clear()
  38.  
  39. W,G,Y=((255,255,255),(0,255,0),(255,255,0))
  40. f1,f2=(u'Normal', 30), (u'Normal', 25)
  41. t1=u'Programming PyS60'
  42. t2=u'A Vertical Text Scroll Demo'
  43. a=img.measure_text(t1,f1)
  44. b=img.measure_text(t2,f2)
  45. distance=h/2+25
  46. while run:
  47.     for i in range(distance):
  48.         t2h=(h-25)-i*4
  49.         color=int(255+i*1.5)
  50.         Bg=(0,color,255)
  51.         img.clear(Bg)
  52.         img.text((5,20),u'* Length: %s'%i, 0)
  53.         img.text(((w-b[0][2])/2,(h-25)-i*4),t2,0,f2)
  54.         img.text(((w-b[0][2])/2-2,(h-25-1)-i*4-2),t2,G,f2)
  55.         img.text(((w-a[0][2])/2,35+i*4),t1,0,f1)
  56.         img.text(((w-a[0][2])/2-2,35-1+i*4-2),t1,Y,f1)
  57.         img.rectangle((0,0,w,h),Y)
  58.         e32.ao_sleep(0.03)
  59.         draw(())
  60.         if not run or t2h < distance: break
  61.     if run: e32.ao_sleep(2)
  62.     e32.ao_yield() # bottom of _running_loop_'''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement