Source

wd_pys60 / wd_about.py

Full commit
##author:weakdancer@gmail.com

import appuifw
from graphics import *
import e32
from key_codes import *

myfont=u'Sans MT 936_S60'
SCREEN_SIZE=(320,240)
layerWidth=SCREEN_SIZE[1]*0.7
backgroundColor=0x000000
layerColor=0x00ff00
running=1

CONTENT=file("e:\\wd_about.txt","r").readlines()

layer=((SCREEN_SIZE[0],(SCREEN_SIZE[1]-layerWidth)/2),(SCREEN_SIZE[0],(SCREEN_SIZE[1]+layerWidth)/2),(0,(SCREEN_SIZE[1]-layerWidth)/2),(0,(SCREEN_SIZE[1]+layerWidth)/2))
img=None
def quit():
    app_lock.signal()

def handle_event(event):
    return None
def handle_redraw(rect):
    if img:
        img.clear(backgroundColor)
        #img.rectangle(layer,layerColor,width=30)
        height=20
        for i in range(0,SCREEN_SIZE[0]+1,height):
            height=abs(height)
            i=abs(i)
            l=((SCREEN_SIZE[1]-layerWidth)/2,i),((SCREEN_SIZE[1]+layerWidth)/2,i)
            for j in range(i-height/2,i+height/2):
                img.line((((SCREEN_SIZE[1]-layerWidth)/2,j),((SCREEN_SIZE[1]+layerWidth)/2,j)),layerColor,width=1)
            try:
                offset=-(SCREEN_SIZE[0]-len(CONTENT)*height)/2
                #offset=0
                textWidth=len(CONTENT[(SCREEN_SIZE[0]-i)/height].replace("\r\n",""))*7.5-CONTENT[(SCREEN_SIZE[0]-i)/height].count(" ")*0.2
                img.text((l[0][0]+(layerWidth-textWidth)/2,l[0][1]+offset),unicode(CONTENT[(SCREEN_SIZE[0]-i)/height].replace("\r\n","")),backgroundColor,font=myfont)
            except:
                pass
        canvas.blit(img)

appuifw.app.screen='full'
appuifw.app.body=canvas=appuifw.Canvas(
    event_callback=handle_event,
    redraw_callback=handle_redraw)

img=Image.new(canvas.size)

appuifw.app.exit_key_handler=quit

handle_redraw(())
app_lock=e32.Ao_lock()
app_lock.wait()