[R-gui] TclTk dynamic dropdown list combo box
Jo?o G. <joaofgo <at> gmail.com> writes:
Thank you! That worked out nicely. I leave here the code used in case it turns out useful for someone else:
If you wanted to do this with gWidgetstcltk you could do this:
library(gWidgets)
options(guiToolkit="tcltk")
d <- mtcars ## some data frame
w <- gwindow()
g <- ggroup(cont=w, horizontal=FALSE)
namesCb <- gcombobox(names(d),selected=1, cont=g)
valsCb <- gcombobox(c(""), cont=g)
updateCb <- function(varname) {
valsCb[] <- d[[varname]]
svalue(valsCb, index=TRUE) <- 1
}
addHandlerChanged(namesCb, function(h,...) updateCb(svalue(h$obj)))
updateCb(svalue(namesCb))
--John