Mobile timeout app
1 2 from appuifw import * 3 from key_codes import * 4 from graphics import Image 5 from audio import * 6 import e32, miso 7 8 def change_duration(): 9 global duration 10 answer = query(u'How long?', 'time', 18000.0) 11 if answer: 12 duration = int(answer/60) 13 if duration <= 200: 14 if query(u'Change to hr:min ?', 'query'): 15 duration *= 60 16 17 im = Image.new((60,48)) 18 def showtime(rect=None): 19 im.clear() 20 im.text((5,28), u"%02d:%02d" % divmod(duration,60), font='title') 21 c.blit(im, target=(0,0,180,144), scale=1) # triple size 22 23 duration = 300 24 running = 0 25 app.body = c = Canvas(showtime) 26 alert = Sound.open(u'Z:\\Nokia\\Sounds\\Digital\\Cuckoo.awb') 27 showtime() 28 29 def start(): 30 global duration, running 31 running = 1 32 while running: 33 duration -= 1 34 showtime() 35 if duration <= 0: 36 alert.play(-2) # repeat play 37 break 38 if duration % 10 == 0: 39 miso.reset_inactivity_time() 40 e32.ao_sleep(1) 41 42 def toggle(): 43 global running 44 if alert.state() == EPlaying: 45 alert.stop() 46 return 47 running = 1 - running 48 if running: 49 start() 50 51 def quit(): 52 global running 53 running = 0 54 if alert.state() == EPlaying: 55 alert.stop() 56 lock.signal() 57 58 lock = e32.Ao_lock() 59 c.bind(EKeySelect, toggle) # start, pause, resume 60 app.menu = [(u'Duration', change_duration),(u'Close', quit)] 61 app.exit_key_handler = quit 62 lock.wait()
Remind yourself of how fast time fly with this app.
You should change the sound file to the one you like.
(I use cuckoo.awb)
The duration input abues the time input by treating input
as minutes and seconds instead of hours and minutes.
But if the duration is too short, it will ask you if you mean
hours and minutes.