Thanks for that link to the mac Gtk2, it's been very helpful. To work around my original problem I've decided to just have the gui be a seperate function that returns the parameter values entered. Then I'll call that function from within a non-gui function -- so have the window close and then the process start, all in a while loop. This won't allow for a button to stop the simulation, but it will do. Thanks for all your help everybody.
Peter On Feb 12, 2008, at 1:56 PM, Michael Lawrence wrote: > On Feb 12, 2008 1:51 PM, Peter McMahan <[EMAIL PROTECTED]> wrote: > >> 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... > > > There are GTK+ binaries available that should work with the RGtk2 CRAN > binary for the Mac. > > http://r.research.att.com/gtk2-runtime.dmg > > >> 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 >>> [EMAIL PROTECTED] >> >> ______________________________________________ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.