Advertisement
here2share

# timer_after_demo.py

Jan 3rd, 2015
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # timer_after_demo.py
  2.  
  3. import time
  4.  
  5. def dts(x=0):
  6.     import datetime
  7.     dt = datetime.datetime.now()
  8.     d = dt.hour, dt.minute, dt.second
  9.     d = "%02d:%02d:%02d" % (d)
  10.     if x:
  11.         d2 =  dt.strftime("%A %d %B %Y ")
  12.         if x is 2:
  13.             d2 += d
  14.         elif x is 3:
  15.             d2 = d2.split()[:-1] + d.split(':')
  16.         return  d2
  17.     return  d
  18.  
  19. print dts()
  20. print dts(1)
  21. print dts(2)
  22. print dts(3)
  23.  
  24. try:
  25.     import e32
  26.     import appuifw
  27.      
  28.     tx=appuifw.Text()
  29.     tx.color=(255,0,0)
  30.     tx.font=(u"Nokia Hindi S6017",36)
  31.     tx.style = appuifw.STYLE_BOLD
  32.     tx.clear()
  33.      
  34.     appuifw.app.body=tx
  35.     tx.add(u"\n3 seconds before printing the current time...\n\n")
  36.  
  37.     running = 1
  38.     def quit():
  39.         global running
  40.         running = 0
  41.     appuifw.app.exit_key_handler = quit
  42.  
  43.     timer = e32.Ao_timer()
  44.  
  45.     appuifw.note(u"Timer Demo...")
  46.     while running:
  47.         tx.add(u"%02d:%02d:%02d ...\n" % (dts()))
  48.         timer.after(3.0) # Note: also can handle milliseconds
  49.  
  50.         e32.ao_yield()
  51.     timer.cancel()
  52. except: pass
  53. #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement