[R] gWidgets - gtable returning multiple values

j verzani jverzani at gmail.com
Sat Jun 16 20:19:05 CEST 2012


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.



More information about the R-help mailing list