runner.py 632 B

12345678910111213141516171819202122232425
  1. import tkinter as tk
  2. import target as target
  3. from sccd.runtime.libs.ui_v2 import UI
  4. from sccd.runtime.tkinter_eventloop import TkEventLoop
  5. class OutputListener:
  6. def __init__(self, ui):
  7. self.ui = ui
  8. def add(self, event):
  9. if event.port == "ui":
  10. method = getattr(self.ui, event.name)
  11. method(*event.parameters)
  12. if __name__ == '__main__':
  13. tkroot = tk.Tk()
  14. tkroot.withdraw()
  15. controller = target.Controller(TkEventLoop(tkroot))
  16. ui = UI(tkroot, controller)
  17. controller.addMyOwnOutputListener(OutputListener(ui))
  18. #controller.setVerbose("./examples/BouncingBalls/Python/trace.txt")
  19. controller.start()
  20. tkroot.mainloop()