[R] R and tcltk Package
Roderick
hruodr @end|ng |rom gm@||@com
Fri Mar 18 08:47:11 CET 2022
Dear John, dear Ivan, thanks a lot.
I am learning R, now trying to learn the Low-level Tcl/Tk Interface,
because I want to write functions programming tcl, with the tcl syntax.
I could do something like .Tcl("source file.tcl"). From there I can
for example do "package require sqlite3", tcl and sqlite combine very
good together. But perhaps also write widgets in the usual tcl/tk form:
why to learn then the R translations of the well known tk commands?
The examples of James Wettenhall are for learning these translations,
perhaps good for someone that do not know tcl/tk and only needs it with R.
We have in R a function as.tclObj() to make objects of class tclObj,
we may make a R list with such objects, like the one generated by
.Tcl.args.objv(), and pass it to the tcl interpreter with .Tcl.objv().
We are calling here tcl from R.
The opposite, with the callbacks, seems not to be possible. We do
not have in the tcl interpreter functions to pass tcl objects as
R objects.
Somethings seems to work:
> g<-function(x,y) print(c(x,y))
> .Tcl.callback(g)
[1] "R_call 0x80ec1d318 %x %y"
That the arguments x, y of g are translated to %x, %y seems to be intended
for using .Tcl.args(g) as script argument for a bind command in tk.
In this case, for reading mouse coordinates. Look:
> tcl("R_call", "0x80ec1d318", 1, 2)
[1] "1" "2"
<Tcl>
But is there an "official way" of calling R functions from tcl in R?
Without doing with tcl strange things with the result of .Tcl.callback()
that I would have to pass to the tcl interpreter in some way?
Thanks
Rodrigo
More information about the R-help
mailing list