tkinter_eventloop.py 449 B

1234567891011121314151617
  1. from statecharts_core import EventLoop
  2. import math
  3. from accurate_time import time
  4. class TkEventLoop(EventLoop):
  5. def __init__(self, tk):
  6. self.ctr = 0
  7. # bind scheduler callback
  8. def schedule(callback, timeout, behind = False):
  9. if behind:
  10. tk.update_idletasks()
  11. return tk.after(int(math.ceil(timeout * 1000.0)), callback)
  12. EventLoop.__init__(self, schedule, tk.after_cancel)