Archived:Simple PySymbian alarm clock for S60 5th Edition
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.
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
Contents |
Introduction
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():
app_lock.signal()
appuifw.app.exit_key_handler=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
timer=e32.Ao_timer()
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()
timer.after(w)
appuifw.note(u"Alarm time" + unicode(note)) #display note on alarm
play_sound() #play sound on alarm
tx=appuifw.Text()
tx.color=(255,0,0)
tx.font=u"Nokia Hindi S6017" # specify font
tx.style = appuifw.STYLE_BOLD
tx.clear() #Clear the window
appuifw.app.body=tx
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
app_lock=e32.Ao_lock()
app_lock.wait()
Screenshots
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)



19 Sep
2009