How do you refresh the contents of an R gWidget?
- by Richie Cotton
I'm creating a GUI in R using gWidgets (more specifically gWidgetstcltk). I'd like to know how to update the contents of selection-type widgets, such as gdroplist and gtable. I currently have a rather hackish method of deleting the widget and re-creating it. I'm sure there's a better way.
This simple example displays all the variables in the global environment.
library(gWidgets)
library(gWidgetstcltk)
create.widgets <- function()
{
grp <- ggroup(container = win)
ddl <- gdroplist(ls(envir = globalenv()),
container = grp)
refresh <- gimage("refresh",
dirname = "stock",
container = grp,
handler = function(h, ...)
{
if(exists("grp") && !is.null(grp))
{
delete(win, grp)
rm(grp)
}
grp <- create.widgets()
}
)
}
win <- gwindow()
grp <- create.widgets()