clock.py 362 B

123456789101112131415
  1. import threading
  2. import time
  3. class Clock(threading.Thread):
  4. def __init__(self,cb):
  5. super(Clock, self).__init__()
  6. self.running = False
  7. self.cb=cb
  8. def run(self):
  9. self.running=True
  10. self.handleTime()
  11. def handleTime(self):
  12. while True:
  13. self.cb(time.strftime("%H:%M"))
  14. time.sleep(15)