[R] Tcl Tk table
James Wettenhall
wettenhall at wehi.edu.au
Mon Apr 26 08:24:12 CEST 2004
Peter Dalgaard wrote:
> do.call("tkcmd", c(list(table1,"tag","cell","gruen"),
> as.list(paste(3:8,3:8),sep=","))
>
> (note btw that .Tk.ID() is wrong, you can just pass the widget
> itself)
I think the sep="," should be inside the paste(3:8,3:8)
brackets i.e. paste(3:8,3:8,sep=","), and there is a closing
bracket missing at the end.
The .Tk.ID() was probably copied from one of my examples. Oops.
I must have been confusing tkcmd(...) with .Tcl(paste(...))
Just to expand on earlier answers, if the table widget has a Tk
ID of .1.1, and you effectively want this Tcl command:
.Tcl(".1.1 tag celltag gruen 3,3 4,4 5,5 6,6 7,7 8,8")
then neither passing "3,3 4,4 5,5 6,6 7,7 8,8" to tkcmd nor
passing c("3,3","4,4","5,5","6,6","7,7","8,8") to tkcmd will
work because in both case the collection of
cell-coordinate-pairs will be passed as a Tcl list which is one
argument of the command whereas you want multiple arguments,
i.e. it will be passed as this Tcl list:
{3,3 4,4 5,5 6,6 7,7 8,8}
or equivalently:
"3,3 4,4 5,5 6,6 7,7 8,8"
To get each cell-coordinate-pair passed as a separate argument,
use do.call or eval(as.call(list(...))), for example:
eval(as.call(list(tkcmd,.Tk.ID(table1),"tag","celltag",
"gruen","3,3","4,4", "5,5","6,6", "7,7", "8,8")))
As noted previously, in R >= 1.8.0 tclArray() is a better way
to handle Tcl arrays.
Regards,
James
More information about the R-help
mailing list