Namespaces
Variants
Actions
(Redirected from A simple screensaver)

Archived:A simple screensaver in PySymbian

Jump to: navigation, search
Archived.png
Aquivado: Este artigo foi arquivado, pois o conteúdo não é mais considerado relevante para se criar soluções comerciais atuais. Se você achar que este artigo ainda é importante, inclua o template {{ForArchiveReview|escreva a sua justificativa}}.

All PySymbian articles have been archived. PySymbian is no longer maintained by Nokia and is not guaranteed to work on more recent Symbian devices. It is not possible to submit apps to Nokia Store.

This is an example of a simple PySymbian screensaver.

Article Metadata

Article
Created: bogdan.galiceanu (29 Mar 2008)
Last edited: hamishwillee (08 May 2013)
import appuifw, e32
from time import *
from graphics import *
 
app_lock=e32.Ao_lock()
def quit():
global running
running=0
app_lock.signal()
appuifw.app.exit_key_handler=quit
 
#We create the background, a blank image
bg=Image.new((240,320)) #These dimensions are purely orientational. For best results, adapt them to your device
 
#Now we create a white rectangle that will hold the date and time, for example
dt=Image.new((240,160))
 
#The screensaver takes up the entire screen
appuifw.app.screen="full"
 
y=0
coord_inc=0
running=1
while(running==1):
if(e32.inactivity()>=5): #The screensaver kicks in after 5 seconds of user inactivity
#The background and the area displaying date and time are cleared
bg.clear()
dt.clear()
 
#The date and time are stored as unicode strings
year=str(localtime()[0])
month=str(localtime()[1])
day=str(localtime()[2])
date=u"%s/%s/%s" % (day,month,year)
if(localtime()[4]<10):min="0"+str(localtime()[4])
else:min=str(localtime()[4])
if(localtime()[5]<10):sec="0"+str(localtime()[5])
else:sec=str(localtime()[5])
time=u"%d:%s:%s" % (localtime()[3],min,sec)
 
#We write the information on the rectangle:
dt.text((80,25), date, font="annotation")
dt.text((70,50), time, font="title")
 
#We place the rectangle on the background
bg.blit(dt, target=(0,y))
#We increase the y coordinate to tell the program where to show the rectangle next
if(coord_inc==0):
y+=160
coord_inc=1 #Tells that y has been increased
else:
y=0
coord_inc=0
 
#We set the background:
def handle_redraw(rect):canvas.blit(bg)
canvas=appuifw.Canvas(event_callback=None, redraw_callback=handle_redraw)
appuifw.app.body=canvas
 
#Tell it to wait 5 seconds before moving the information
e32.ao_sleep(5)


Screenshot:


Saver.JPG

This page was last modified on 8 May 2013, at 09:23.
266 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved