Esempio n. 1
0
// Creates a new instance of the *gothic.Interpreter. But before interpreter
// enters the Tk's main loop it will execute `init`. Init argument could be a
// string or a function with this signature: "func(*gothic.Interpreter)".
func NewInterpreter(preinit interface{}, init interface{}) *Interpreter {
	initdone := make(chan int)
	done := make(chan int)

	ir := new(Interpreter)
	ir.Done = done

	go func() {
		var err error
		runtime.LockOSThread()
		ir.ir, err = new_interpreter(preinit)
		if err != nil {
			panic(err)
		}

		switch realinit := init.(type) {
		case string:
			err = ir.ir.eval([]byte(realinit))
			if err != nil {
				panic(err)
			}
		case func(*Interpreter):
			realinit(ir)
		}

		initdone <- 0
		C.Tk_MainLoop()
		done <- 0
	}()

	<-initdone
	return ir
}
Esempio n. 2
0
// The event loop
func MainLoop() {
	C.Tk_MainLoop()
}
Esempio n. 3
0
func (ir *Interpreter) MainLoop() {
	ir.thread = C.Tcl_GetCurrentThread()
	C.Tk_MainLoop()
}