Liviu Andronic
Fri, 26 Feb 2010 06:44:30 -0800
On 2/26/10, Michael Lawrence <lawrence.mich...@gene.com> wrote: > You probably want to change the for() loop to an lapply construct, so that > you are creating a unique closure around each handler. Otherwise, they'll > both see the same value of 'k' (whatever it was set to last). > Indeed, thanks! On quick check, the following does what I originally intended. Liviu
count.pop3 <- function(fun=c("count.mv.int", "count.mv.let")){
require(gWidgets)
options(guiToolkit="tcltk")
w <- gwindow(paste("Counters (lapply)"))
g <- ggroup(cont=w, horizontal=T)
x.fun <- function(k){
x.cont <- paste("g", i, sep="")
assign(x.cont, ggroup(cont=g, horizontal=FALSE))
glabel(paste("'", fun[k], "'", sep=""), cont=get(x.cont))
x.handl <- paste("h", i, sep="")
assign(x.handl, function(h,...) eval(parse(text=paste(fun[k],
"(svalue(h$obj))", sep=""))))
x.sl <- paste("s", i, sep="")
assign(x.sl, gslider(from=formals(fun[k])$start,
to=formals(fun[k])$end,
by=1, cont=get(x.cont), handler=get(x.handl)))
gseparator(horizontal=FALSE, cont=g, expand=TRUE)
}
lapply(1:length(fun) , x.fun)
}
count.pop3()
_______________________________________________
R-SIG-GUI mailing list
R-SIG-GUI@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-gui