×
Namespaces

Variants
Actions
Revision as of 05:26, 27 July 2012 by hamishwillee (Talk | contribs)

Archived:A simple timeout application using PySymbian

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Article
Created: cyke64 (19 Mar 2007)
Last edited: hamishwillee (27 Jul 2012)

Remind yourself of how fast time fly with this application. You should change the sound file to the one you like.

from appuifw import *
from key_codes import *
from graphics import Image
from audio import *
import e32, miso
 
def change_duration():
global duration
answer = query(u'How long?', 'time', 18000.0)
if answer:
duration = int(answer/60)
if duration <= 200:
if query(u'Change to hr:min ?', 'query'):
duration *= 60
 
im = Image.new((60,48))
def showtime(rect=None):
im.clear()
im.text((5,28), u"%02d:%02d" % divmod(duration,60), font='title')
c.blit(im, target=(0,0,180,144), scale=1) # triple size
 
duration = 300
running = 0
app.body = c = Canvas(showtime)
alert = Sound.open(u'Z:\\Nokia\\Sounds\\Digital\\Cuckoo.awb')
showtime()
 
def start():
global duration, running
running = 1
while running:
duration -= 1
showtime()
if duration <= 0:
alert.play(-2) # repeat play
break
if duration % 10 == 0:
miso.reset_inactivity_time()
e32.ao_sleep(1)
 
def toggle():
global running
if alert.state() == EPlaying:
alert.stop()
return
running = 1 - running
if running:
start()
 
def quit():
global running
running = 0
if alert.state() == EPlaying:
alert.stop()
lock.signal()
 
lock = e32.Ao_lock()
c.bind(EKeySelect, toggle) # start, pause, resume
app.menu = [(u'Duration', change_duration),(u'Close', quit)]
app.exit_key_handler = quit
lock.wait()
59 page views in the last 30 days.