Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # vertical_text_scroll.py
- import os,sys,time,math,random
- import appuifw,graphics,key_codes,e32,audio,sensor
- from appuifw import *
- from graphics import *
- run=1
- def exit():global run; run=0
- app.exit_key_handler=exit
- app_lock=e32.Ao_lock()
- def draw(rect):
- try: canvas.blit(img)
- except: pass
- img=None
- appuifw.app.screen='large'
- appuifw.app.orientation='portrait'
- appuifw.app.directional_pad=False
- appuifw.app.body=canvas=Canvas(redraw_callback=draw)
- img=Image.new(canvas.size)
- w, h=canvas.size
- def up_event(event):
- pass
- def dn_event(event):
- pass
- canvas.bind(key_codes.EButton1Up, up_event, ((0,0), (w,h)))
- canvas.bind(key_codes.EButton1Down, dn_event, ((0,0), (w,h)))
- def mv_event(event):
- pass
- canvas.bind(key_codes.EDrag, mv_event, ((0,0), (w,h)))
- img.clear()
- W,G,Y=((255,255,255),(0,255,0),(255,255,0))
- f1,f2=(u'Normal', 30), (u'Normal', 25)
- t1=u'Programming PyS60'
- t2=u'A Vertical Text Scroll Demo'
- a=img.measure_text(t1,f1)
- b=img.measure_text(t2,f2)
- distance=h/2+25
- while run:
- for i in range(distance):
- t2h=(h-25)-i*4
- color=int(255+i*1.5)
- Bg=(0,color,255)
- img.clear(Bg)
- img.text((5,20),u'* Length: %s'%i, 0)
- img.text(((w-b[0][2])/2,(h-25)-i*4),t2,0,f2)
- img.text(((w-b[0][2])/2-2,(h-25-1)-i*4-2),t2,G,f2)
- img.text(((w-a[0][2])/2,35+i*4),t1,0,f1)
- img.text(((w-a[0][2])/2-2,35-1+i*4-2),t1,Y,f1)
- img.rectangle((0,0,w,h),Y)
- e32.ao_sleep(0.03)
- draw(())
- if not run or t2h < distance: break
- if run: e32.ao_sleep(2)
- e32.ao_yield() # bottom of _running_loop_'''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement