nsf / gothic

Tcl/Tk Go bindings
MIT License
151 stars 24 forks source link

Great library! One question - How to get the result of tcl/tk function call #19

Open john157157 opened 2 years ago

john157157 commented 2 years ago

Any time I try to get information from tcl/tk I do an Eval like this:

` i := ir.Eval("[winfo screenheight .]")

fmt.Println(i) `

and it produces a response like this: invalid command name "1080"

Obviously tcl is trying to execute the result of the winfo call. Same thing happens with different functions and it doesn't matter if I put the results into a tcl variable first and then read the variable.

I can always strip the "invalid command name" and the quotes and have the result I need but that doesn't seem like the 'A' plan. Anybody know what I'm doing wrong?

Btw, I really am enjoying this library. Gothic and Golang templates go well together.

john157157 commented 2 years ago

It looks like setting a dummy variable and getting the result from one of the EvalAs() functions is the way it's done.

` s, _ := ir.EvalAsString("set dummyvar [winfo screenheight .]")

Edit: (better answer) s, _ := ir.EvalAsString("return [winfo screenheight .]")

`