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. Thanks for all your past and future contributions.

Revision as of 01:02, 31 May 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Archived:A simple stopwatch example using PySymbian

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
Created: cyke64 (19 Mar 2007)
Last edited: hamishwillee (31 May 2013)

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)
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.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
self.running = 1
self.time_start = time.clock() - self.elap
def reset(self):
self.running = 0
self.elap = 0.0
sw = StopWatch()
lock = e32.Ao_lock() = [(u'Reset', sw.reset), (u'Close', lock.signal)]
app.exit_key_handler = lock.signal


Python stopwatch.JPG

This page was last modified on 31 May 2013, at 01:02.
46 page views in the last 30 days.