tkgrid にリストを投げるとエラーを頂戴するので、足掻いてみました。
この場合は単に do.call
で OK、勉強不足でした。
require(tcltk) tt <- tktoplevel() b1 <- tkbutton(tt, text = "OK 1", command = function() tkdestroy(tt)) b2 <- tkbutton(tt, text = "OK 2", command = function() tkdestroy(tt)) b3 <- tkbutton(tt, text = "OK 3", command = function() tkdestroy(tt)) b4 <- list(b1, b2, b3) do.call(tkgrid, b4)
require(tcltk) tt <- tktoplevel() b1 <- tkbutton(tt, text = "OK 1", command = function() tkdestroy(tt)) b2 <- tkbutton(tt, text = "OK 2", command = function() tkdestroy(tt)) b3 <- tkbutton(tt, text = "OK 3", command = function() tkdestroy(tt)) b4 <- list(b3, b2, b1) listRecall <- function(l, fun, ...) { listLength <- length(l) if (listLength <= 1) { fun(l[[1]], ...) } else { Recall(l[2:listLength], fun, l[[1]], ...) } } listRecall(b4, tkgrid)