# NOT RUN {
flavors <- c("vanilla", "chocolate", "strawberry")
w <- gwindow("Radio example", visible=FALSE)
gp <- ggroup(container=w)
glabel("Favorite flavor:",container=gp, anchor=c(0,1))
rb <- gradio(flavors, container=gp)
addHandlerClicked(rb, handler=function(h,..) {
cat(sprintf("You picked %s\n", svalue(h$obj)))
})
visible(w) <- TRUE
betterFlavors <- c("coffee", "mint chip")
rb[] <- betterFlavors
rb[] <- c(betterFlavors, "chocolate") # some toolkits don't allow change of length
rb[3] <- "mango sorbet" ## can change a label name
## set values
svalue(rb) <- "coffee" ## by name
svalue(rb, index=TRUE) <- 1 ## by index
## get selected values
svalue(rb)
svalue(rb, index=TRUE)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab