How do you refresh the contents of an R gWidget?
Posted
by Richie Cotton
on Stack Overflow
See other posts from Stack Overflow
or by Richie Cotton
Published on 2010-04-21T12:00:43Z
Indexed on
2010/04/21
12:03 UTC
Read the original article
Hit count: 271
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()
© Stack Overflow or respective owner