flavors <- c("vanilla", "chocolate", "strawberry")
w <- gwindow("Radio example")
gp <- ggroup(container=w)
glabel("Favorite flavor:",cont=gp, anchor=c(0,1))
rb <- gradio(flavors, cont=gp)
addHandlerClicked(rb, handler=function(h,..) {
cat(sprintf("You picked })
betterFlavors <- c("coffee", "mint chip")
rb[] <- betterFlavors ## tcltk won't be happy -- needs 3 flavors
rb[] <- c(betterFlavors, "chocolate") ## to make tcltk happy
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)
Run the code above in your browser using DataLab