Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Archived:Simple PySymbian alarm clock for S60 5th Edition

From 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
Compatibility
Platform(s):
S60 5th Edition
Article
Created: croozeus (14 Oct 2008)
Last edited: hamishwillee (31 May 2013)


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

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.
54 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.

×