Skip to content

[R-gui] tktable topleft

2 messages · David Katz, j verzani

1 day later
#
David Katz <david <at> davidkatzconsulting.com> writes:
The topleft index refers to the top left editable cell. Try the 0,0 index, as in
the code below:

library(tcltk)
tclRequire("Tktable")
a <- tclArray()
m <- rbind(c("","h1","h2"),
           c("r1", "1", "2"),
           c("r2", "3", "4"))
## col. headings
sapply(2:ncol(m), function(j) 
       a[[0,j-1]] <- as.tclObj(m[1,j]))
## fill in row by row
sapply(2:nrow(m), function(i)
       sapply(1:ncol(m), function(j)
              a[[i-1, j-1]] <- as.tclObj(m[i,j])))

w <- tktoplevel()
tbl <- tkwidget(w, "table", variable=a,
                rows = nrow(m),
                cols = ncol(m),
                titlerows=1, titlecols=1)
tkpack(tbl)


## adjust upper cell
tkset(tbl,"0,0","text")

--John