티스토리 뷰
import threading import time class ExTimer(threading.Thread): def __init__(self): threading.Thread.__init__(self) # default delay set.. self.delay = 1 self.state = True self.handler = None def setDelay(self, delay): self.delay = delay def run(self): while self.state: time.sleep( self.delay ) if self.handler != None: self.handler() def end(self): self.state = False def setHandler(self, handler): self.handler = handler def timerHandler(): print "Timer" th = ExTimer() th.setHandler(timerHandler) th.setDelay(0.5) th.start()
Python 매력이 넘치네~
'Programming Languages > Python' 카테고리의 다른 글
Python을 이용한 간단 웹서버 (0) | 2016.01.01 |
---|---|
Python Tokenizer str.split() (1) | 2011.11.20 |
Panda3D 윈도우 속성을 내 마음대로 WindowProperties Class (0) | 2011.08.07 |
Python 쓰레드(Thread) (0) | 2011.08.01 |
Python for loop 와 while loop (0) | 2011.08.01 |
댓글
01-03 00:52
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday