[R] gWidgets process management

Peter McMahan mcmahan at uchicago.edu
Tue Feb 12 20:51:32 CET 2008


Thanks, that's very helpful. Unfortunately Gtk2 is difficult to get  
running on a Mac, so I've been trying the gWidgetstcktk interface.
It sounds like the behavior you're describing is exactly what I want,  
so it may just be a difference in the TGtk2 and tcltk event loops?
In your example, can you think of a way to have a "cancel" button that  
would be able to kill reallySlowFunction() early?
for the time being, I guess I'll just work on getting the gtk28  
package from macports working...
Thanks,
Peter

On Feb 12, 2008, at 1:31 PM, John Verzani wrote:

> Dear Peter,
>
> I think this issue has more to do with the event loop than gWidgets.
> I've cc'ed Michael Lawrence, who may be able to shed more light on
> this. Perhaps gIdleAdd from RGtk2 can work around this, but I didn't
> get anywhere. My understanding is that the event loop is preventing
> the console from being interactive, but not GTK events. So for
> instance, the GUI in the following example is responsive, during the
> execution, but the command line is not.
>
> library(gWidgets)
> options("guiToolkit"="RGtk2")
>
> reallySlowFunction = function(n=20) {
>  for(i in 1:n) {
>    cat("z")
>    Sys.sleep(1)
>  }
>  cat("\n")
> }
>
>
> w <- gwindow("test")
> g <- ggroup(cont=w, horizontal=FALSE)
> b <- gbutton("click me", cont=g,handler = function(h,...)  
> reallySlowFunction())
> r <- gradio(1:3, cont=g, handler = function(h,...) print(svalue(h 
> $obj)))
>
> ## you can click the radio button and get a response, but not the  
> console
>
>
> --John
>
>
> Hello,
> I'm trying to make a graphical interface for an R function
> I've written. A common use for the function is to call it with
> specific parameters, and then watch the output as it evolves.
> There's not necessarily a logical stopping point, so I usually
> use ctrl-C when I'm done to stop it.
> I've made a gWidgets interface to the function that gets some
> user info and then on a button click calls the function. The
> gWidgets window, however, seems to be frozen as long as the
> function is running, and the function output seems to be
> happening in the "background" in my R session, so ctrl-C (esc
> on the Mac GUI) does not work to stop it. I have to kill R
> entirely to stop the process.
> So after all that setup here is my question:
> Is there some way to have a gWidgets window interrupt a
> function that it has called via a widget handler?
> Thanks,
> Peter
>
> -- 
> John Verzani
> CUNY/CSI Department of Mathematics
> verzani at math.csi.cuny.edu



More information about the R-help mailing list