Hello, I am having some trouble finding a solution for a probleIm I am facing with the package gWidgets. Here is the code: flavors<-c("vanilla", "chocolate", "strawberry") f<-function(h,...)print(svalue(h$obj)) w <- gwindow("checkbox example") gp <- ggroup(container=w) glabel("Favorite flavors:",cont=gp) cbg <- gtable(flavors, cont=gp, handler=f,multiple=T) I get only 1 value, instead of all of the selected values. Does anybody know how to return all the selected values? Any help will be greatly appreciated! Thanks in advance -- View this message in context: http://r.789695.n4.nabble.com/gWidgets-gtable-returning-multiple-values-tp4633296.html Sent from the R help mailing list archive at Nabble.com.
To whoever is looking for the same thing as I was, I found a solution, or sort of. Here is the code: flavors<-c("vanilla", "chocolate", "strawberry") w <- gwindow("checkbox example") gp <- ggroup(container=w) glabel("Favorite flavors:",cont=gp) cbg <- gtable(flavors, cont=gp, multiple=T) # Here is the trick addHandlerClicked(cbg,handler=function(h,...){ My_Flav<-svalue(cbg) print(My_Flav) }) Select multiple lines, and you shall see all the selected rows. -- View this message in context: http://r.789695.n4.nabble.com/gWidgets-gtable-returning-multiple-values-tp4633296p4633450.html Sent from the R help mailing list archive at Nabble.com.
michaelyb <cel81009759 <at> gmail.com> writes:> > To whoever is looking for the same thing as I was, > I found a solution, or > sort of. > Here is the code: > > flavors<-c("vanilla", "chocolate", "strawberry") > > w <- gwindow("checkbox example") > gp <- ggroup(container=w) > glabel("Favorite flavors:",cont=gp) > cbg <- gtable(flavors, cont=gp, multiple=T) > > # Here is the trick > addHandlerClicked(cbg,handler=function(h,...){ > My_Flav<-svalue(cbg) > print(My_Flav) > }) > > Select multiple lines, and you shall see all the selected rows. >Can you check if the following runs? It worked for me so it may be an older version (on gWIdgetsRGtk2 and gWidgetstcltk) w <- gwindow(visible=FALSE) g <- ggroup(cont=w, horizontal=FALSE) tbl <- gtable(mtcars[1:5,], cont=g, multiple=TRUE, expand=TRUE) b <- gbutton("click", cont=g, handler=function(h,...) { print(svalue(tbl)) }) visible(w) <- TRUE svalue(tbl, index=TRUE) <- 1:2 print(svalue(tbl, index=TRUE)) You should see 1 2 on the console and the first and second rows should appear selected.