Categories: S60 | Python | Code Examples
This page was last modified 19:25, 18 June 2008.
A simple stopwatch example
From Forum Nokia Wiki
It can start, stop, start again, and reset. Use select key and menu.
from appuifw import * from key_codes import * import e32, time class StopWatch: running = 0 time_start = None elap = 0.0 def __init__(self): self.canvas = Canvas(self.update) app.body = self.canvas self.canvas.bind(EKeySelect, self.toggle) self.update() def update(self, rect=None): if self.running: self.elap = time.clock() - self.time_start e32.ao_sleep(0.05, self.update) t = self.elap min = int(t / 60) sec = int(t - min*60) hsec = int((t - min*60 - sec)*100) self.canvas.clear() self.canvas.text((20,40), u"%02d:%02d:%02d" % (min,sec,hsec), font='title') def toggle(self): if self.running: self.running = 0 self.elap = time.clock() - self.time_start else: self.running = 1 self.time_start = time.clock() - self.elap self.update() def reset(self): self.running = 0 self.elap = 0.0 self.update() sw = StopWatch() lock = e32.Ao_lock() app.menu = [(u'Reset', sw.reset), (u'Close', lock.signal)] app.exit_key_handler = lock.signal lock.wait()
Screenshot:
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| J2ME wireless tool kit program | rousseau | Mobile Java Tools & SDKs | 2 | 2006-12-16 00:07 |
| MIDlet does not launch | glmuelle | Mobile Java General | 3 | 2006-01-26 12:26 |
| Splash Screen Problem | ash_21 | General Symbian C++ | 25 | 2007-09-06 13:50 |
| Nokia 6630 didn't ask access points and didn't connect. | developer-che | Mobile Java Networking & Messaging & Security | 10 | 2006-05-10 17:14 |
| Nokia 6600 socket | pkien168 | Mobile Java Networking & Messaging & Security | 0 | 2004-05-04 04:38 |
