[R-gui] Process control in gWidgets

Hana Sevcikova hana at cs.washington.edu
Tue Aug 11 08:29:32 CEST 2009


Thank you very much, John. I am indeed using gWidgetsRGtk2 but I was 
hoping to make my GUI independent of the specific toolkit. But there is 
probably no easy solution. Even with the gtkEventsPending() and 
gtkMainIteration() I don't get the output into the R-console as the 
computation runs, rather at the very end.

Please let me know if you get other ideas how to solve it.

Thanks,

Hana


jverzani wrote:
> Hana Sevcikova <hana <at> cs.washington.edu> writes:
> 
>> Hello,
>>
>> I implemented a GUI (using gWidgets) from which I'd like to start a long 
>> process by clicking a button. This process prints out status messages 
>> which the user should be able to see in the R console during the 
>> computation. But at the moment clicking the button freezes the GUI until 
>> the process is finished and all output is printed at the end. Is there a 
>> way how to do this? The process can take several hours and during that 
>> time I need to make the GUI available for other tasks.
>>
> 
> Dear Hana,
> 
> This post was followed up with
> https://stat.ethz.ch/pipermail/r-help/2008-February/154249.html where a
> combination of gtkEventsPending() and  gtkMainIteration() is used to update the
> GUI during a computation. This could work for you if a) you are using
> gWidgetsRGtk2 through gWidgets and b) you can add this within your long
> computation. If that doesn't work out, let me know. 
> 
> --John
> 
> 
>> I found a similar post on R-help from last year where John Verzani 
>> posted the following test code:
>>
>> 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)))
>>
>> I cannot figure out why my GUI freezes and this one not but
>> here again, the output of reallySlowFunction is printed at the very end 
>> after the process finishes. Would anybody know how to solve it?
>>
>> Thanks,
>>
>> Hana
>>
> 
> _______________________________________________
> R-SIG-GUI mailing list
> R-SIG-GUI at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-gui



More information about the R-SIG-GUI mailing list