runner.py 806 B

1234567891011121314151617181920212223242526272829303132333435
  1. '''
  2. Created on 27-jul.-2014
  3. @author: Simon
  4. '''
  5. import tkinter as tk
  6. import target as target
  7. from sccd.runtime.libs.ui_v2 import UI
  8. from sccd.runtime.tkinter_eventloop import TkEventLoop
  9. from sccd.runtime.statecharts_core import Event
  10. class OutputListener:
  11. def __init__(self, ui):
  12. self.ui = ui
  13. def add(self, event):
  14. if event.port == "ui":
  15. method = getattr(self.ui, event.name)
  16. method(*event.parameters)
  17. if __name__ == '__main__':
  18. tkroot = tk.Tk()
  19. tkroot.withdraw()
  20. controller = target.Controller(TkEventLoop(tkroot))
  21. ui = UI(tkroot, controller)
  22. controller.addMyOwnOutputListener(OutputListener(ui))
  23. controller.setVerbose("./examples/BouncingBalls/Python/trace.txt")
  24. actual_event = Event("hello", "ui")
  25. controller.addInput(actual_event, 500)
  26. controller.start()
  27. tkroot.mainloop()