#!/bin/env python2 import Tkinter as tk import chatwindow from sccd.runtime.statecharts_core import Event from sccd.runtime.tkinter_eventloop import * import threading import sys from sccd_widget import SCCDWidget class Root(tk.Tk, SCCDWidget): def __init__(self): tk.Tk.__init__(self) SCCDWidget.__init__(self) root = Root() root.withdraw() controller = chatwindow.Controller(TkEventLoop(root)) SCCDWidget.controller = controller def stdin_poller(controller): while 1: controller.addInput(Event("stdin_input", "stdin_port", [raw_input()])) def stdout_printer(controller): port = controller.addOutputListener("stdout_port") while 1: sys.stdout.write(port.fetch(-1).parameters[0] + "\n") sys.stdout.flush() input_thread = threading.Thread(target=stdin_poller, args=[controller]) input_thread.daemon = True input_thread.start() output_thread = threading.Thread(target=stdout_printer, args=[controller]) output_thread.daemon = True output_thread.start() controller.start() root.mainloop()