[R] How to mimic select.list using RGtk2/gWidgetsRGtk2?

ronggui ronggui.huang at gmail.com
Fri Dec 12 18:14:59 CET 2008


I want to write a function mimic the function of select.list(), here
is my preliminary version.

select <- function(x,multiple=TRUE,...){
ans<-new.env()
g <- gwindow(title=title,wid=200,heigh=500)
x1<-ggroup(FALSE,con=g)
x2<-gtable(x,multiple=multiple,con=x1,expand=TRUE)
gbutton("OK",con=x1,handler=function(h,...){
value <- svalue(x2)
if (length(value)==0) value=""
assign("selected",value,env=h$action$env)
dispose(x1)
},action=list(env=ans))
ans
}

However, it doesn't behave as what I want.  What I want is that: for
{select(c("a","b")); foo()}, foo() only runs after I have clicked the
OK button of select(). Any hints?

Thanks.
-- 
HUANG Ronggui, Wincent
Tel: (00852) 3442 3832
PhD Candidate, City University of Hong Kong
Website: http://ronggui.huang.googlepages.com/
RQDA project: http://rqda.r-forge.r-project.org/



More information about the R-help mailing list