[R-gui] Idle/timer callbacks in tk widgets

Peter Dalgaard p.dalgaard at biostat.ku.dk
Mon Jan 8 20:43:57 CET 2007


Stephen Eglen wrote:
> Hi,
>
> I have some spatiotemporal data that I currently visualise by doing a
> simple loop, along the lines of:
>
> for (t in 1:100) {
>   plot.data(t)
> }
>
> plot.data(t) is a simple function that displays a 2-d plot in an R
> window of the data at time t.
>
> This is okay, but quite restrictive (e.g. currently I have to Ctrl-C
> to break out of the loop); I'd like to build a simple GUI (in tk) that
> would provide a slider to control where to start showing the data
> from, and start/stop buttons to control display of the data.
>   
I'm not quite sure exactly what you want, but I think you might want to 
check out Tcl's "after" command, e.g.

f <- function() {tcl("puts", n) ; if (n <<- n-1) tcl("after", 1000, f)}

n <- 10

f()

> I've looked at some of the online resources (including the very useful
> set of tk scripts at
> http://bioinf.wehi.edu.au/~wettenhall/RTclTkExamples/ but I can't seem
> to find anything like this.  Ousterhout's book (Tcl and the Tk
> Toolkit) mentions on page 400 timer events, such as
> Tk_CreateTimerHandler, which may be useful.  But has anyone ventured
> in this direction before?
>
> Thanks, Stephen
>
> p.s. The link to GraspeR on
>   http://www.sciviews.org/_rgui/projects/TclTk.html is broken; a newer
> link is http://www.cscf.ch/grasp/grasp-r/index.html
>
> _______________________________________________
> 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