Categories: Python | Code Examples | S60 | How To
This page was last modified 15:04, 29 March 2008.
A simple screensaver
From Forum Nokia Wiki
This is an example of a simple PyS60 screensaver.
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:
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help: 6600 Screensaver - Has anyone else noticed this ? | ozzy_1971 | General Symbian C++ | 0 | 2004-02-25 18:50 |
| 7210 Screensavers,Enhanced Memory.... | baavlaa | General Discussion | 1 | 2003-03-31 23:33 |
| Profile + Screensaver -- Help! | s60developer | Symbian Media (Graphics & Sounds) | 0 | 2005-03-01 16:38 |
| I need 2 know when the screensaver of the Nokia 7650 started | Sash18 | Symbian User Interface | 0 | 1970-01-01 02:00 |
| Express signing : UNI-01 step-7 : system lock | ajitac | Symbian Signing, Certification and Security | 7 | 2008-01-31 08:03 |
