Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # timer_after_demo.py
- import time
- def dts(x=0):
- import datetime
- dt = datetime.datetime.now()
- d = dt.hour, dt.minute, dt.second
- d = "%02d:%02d:%02d" % (d)
- if x:
- d2 = dt.strftime("%A %d %B %Y ")
- if x is 2:
- d2 += d
- elif x is 3:
- d2 = d2.split()[:-1] + d.split(':')
- return d2
- return d
- print dts()
- print dts(1)
- print dts(2)
- print dts(3)
- try:
- import e32
- import appuifw
- tx=appuifw.Text()
- tx.color=(255,0,0)
- tx.font=(u"Nokia Hindi S6017",36)
- tx.style = appuifw.STYLE_BOLD
- tx.clear()
- appuifw.app.body=tx
- tx.add(u"\n3 seconds before printing the current time...\n\n")
- running = 1
- def quit():
- global running
- running = 0
- appuifw.app.exit_key_handler = quit
- timer = e32.Ao_timer()
- appuifw.note(u"Timer Demo...")
- while running:
- tx.add(u"%02d:%02d:%02d ...\n" % (dts()))
- timer.after(3.0) # Note: also can handle milliseconds
- e32.ao_yield()
- timer.cancel()
- except: pass
- #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement