[R] Tcl Tk table

Peter Dalgaard p.dalgaard at biostat.ku.dk
Mon Apr 26 10:11:45 CEST 2004


James Wettenhall <wettenhall at wehi.edu.au> writes:

> 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.

Right, thanks. I didn't have tktable to hand so I couldn't check...
 
> 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. 

Doesn't really help with tagging though (or does it?)

BTW, .Tk.ID sneaked in again... I wonder what is the cleanest way of
doing this stuff. This works (inserting "list" to compensate for
absence of tktable):

> part1 <- .Tcl.args.objv("list",tt,"tag","celltag","gruen")
> part2 <- as.list(paste(3:8,3:8,sep=","))
> do.call("tkcmd",c(part1,part2))
<Tcl> .1 tag celltag gruen 3,3 4,4 5,5 6,6 7,7 8,8

as does this:

> part1 <- .Tcl.args.objv("list",tt,"tag","celltag","gruen")
> part2 <- lapply(paste(3:8,3:8,sep=","),as.tclObj)
> .Tcl.objv(c(part1,part2))
<Tcl> .1 tag celltag gruen 3,3 4,4 5,5 6,6 7,7 8,8

However, having any dot-function called by the user signals a design
problem to me (especially since .Tcl.objv does not check its arguments
at all, so BadThings will happen if you pass it something that is not
a list of tclObj's).

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list