'namespace: locals send to InteractiveConsole object
commands: list of commands executed at startup'

def __init__(self, namespace=None, exitfunc=None, Output=None, WidgetProxy=None, debug=False):

    InteractiveConsole.__init__(self, namespace)
    threading.Thread.__init__(self)
    self._id = None
    self.exit_flag = False
    self.debug = debug
    self.more = False
    if (exitfunc is not None):
        atexit.register(exitfunc)
    self.namespace = self.locals
    self.namespace['__name__'] = '__main__'
    self.namespace['execfile'] = self.execfile
    self.namespace['runfile'] = self.runfile
    self.namespace['raw_input'] = self.raw_input_replacement
    self.namespace['help'] = self.help_replacement
    self.initial_stdout = sys.stdout
    self.initial_stderr = sys.stderr
    self.initial_stdin = sys.stdin
    (pr, pw) = os.pipe()
    self.stdin_read = os.fdopen(pr, 'r')
    self.stdin_write = os.fdopen(pw, 'wb', 0)
    self.stdout_write = Output()
    self.stderr_write = Output()
    self.input_condition = threading.Condition()
    self.widget_proxy = WidgetProxy(self.input_condition)
    self.redirect_stds()
