[R-gui] equivalent of "modal" widgets in gWidgetsRGtk2
Sebastian P. Luque
spluque at gmail.com
Fri Jul 18 20:25:02 CEST 2008
Hi,
Hopefully this example shows what I'm trying to do:
doPlot <- function() {
updatePlot <- function(h, ...) plot(rnorm(10))
## collect locator() coordinates
coords <- list()
loc.fun <- function() {
coords[[length(coords) + 1]] <<- locator(1)
}
tblist <- list(quit=list(handler=function(h, ...) dispose(window)),
plot=list(handler=updatePlot),
loc.but=list(handler=loc.fun))
window <- gwindow("gWidgetsDensity")
## Little menu bar
add(window, gtoolbar(tblist))
bigGroup <- ggroup(container=window)
add(bigGroup, ggraphics(), expand=TRUE)
invisible(coords)
}
This has a tool bar with 3 buttons: quit, plot and a loc.but. The
latter calls locator to collect some coordinates from the plot. The
loc.but button tries to call locator() and collects results in a list;
one element per click. So the function should not exit until the window
is destroyed. The function tries to return the collected coordinates
invisibly, but the problem is that it exits before anything is done
through the GUI. In tcltk this was done with tkwait.window(<<base
frame>>). How can this be done in gWidgetsRGtk2? Thanks.
Cheers,
--
Seb
More information about the R-SIG-GUI
mailing list