Archived:Simple PySymbian alarm clock for S60 5th Edition

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngAquivado: 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.

Article Metadata
S60 5th Edition
Created: croozeus (14 Oct 2008)
Last edited: hamishwillee (31 May 2013)



Here is a small code snippet which creates a Alarm Clock in Python.This application is designed to make an alert sound at a specific date and/or time. The application is tested on S60 5th Edition SDK but the code below can also be used with S60 5th Edition pre-releases (some changes might be required for porting). Learn how to use PySymbian with 5th Edition SDK here: Archived:PySymbian for 5th Edition with sample applications.

Code Snippet

Below is the code snippet for Alarm clock application.

import e32
import time
import appuifw
def quit():
def play_sound():
from audio import *
f = 'C:\\Nokia\\Sounds\\Digital\\28050.amr'
s = Sound.open(f)#open sound file
s.play()#play sound file
def alarm(): #function to compare time.
def wait():
t = list(time.localtime())
n = time.mktime(t)
t[3] = t[4] = t[5] = 0
t[2] += 1
return time.mktime(t) - n
w = wait()
while w > 60:
h = w / 3600
m = w % 3600 / 60
s = w % 60
print "Alarm on !"
print "waiting %02d:%02d:%02d ..." % (h, m, s)
timer.after(s or 60)
w = wait()
appuifw.note(u"Alarm time" + unicode(note)) #display note on alarm
play_sound() #play sound on alarm
tx.font=u"Nokia Hindi S6017" # specify font
tx.style = appuifw.STYLE_BOLD
tx.clear() #Clear the window
tx.add(u"The Current Time is "+ unicode(time.localtime())
tx.add(u"\n >Click options to set new alarm")
appuifw.app.menu=[(u'Quick Alarm', alarm),(u'Exit', quit)] # Set menu options


Alarm 5thSDK.jpg

Further Development

A lot of improvements can be done to the code presented in this article. For example,

  • The graphics of the application can be customized using the graphics module.
  • A topwindow or a pop-up alert could be added.

See Also

Archived:PySymbian for 5th Edition with sample applications

This article is authored by croozeus 14:03, 14 October 2008 (EEST)

This page was last modified on 31 May 2013, at 01:10.
37 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.