[Rd] rerender tcltk toplevel

Florian Hahne fhahne at gmx.de
Mon May 22 11:17:28 CEST 2006


Hi everybody,
I am trying to write a simple progress display based on a tcltk
toplevel. My first approach was to use  the progressBar widget from the
BWidget library but since this is not available on every system (missing
on at least almost all windows systems, I guess...) I wanted to have a
backup there. So my second strategy was to use a simple toplevel with a
label and update the tclvariable assigned to it. This works nicely on
windows systems but on my linux box (Suse10) the label is not updated on
every round of iteration but rather once the iterator finishes.

tt <-tktoplevel()
tkwm.geometry(tt, "250x140")
prog <-  tclVar("0")
label <- tklabel(tt, textvariable=prog)
tkgrid(label)

for(i in 1:50) {
    tmp <- rnorm(1e+05)
    tclvalue(prog) <- i*2
}

When I combine both approaches and add the label to a toplevel that
already contains the progress bar updating the label works:

tt <-tktoplevel()
tkwm.geometry(tt, "250x140")
prog <-  tclVar("0")
label <- tklabel(tt, textvariable=prog)
progBar <- tkwidget(tt, "ProgressBar", variable=prog)
tclRequire("BWidget")
tkgrid(progBar)
tkgrid(label)

for(i in 1:50) {
    tmp <- rnorm(1e+05)
    tclvalue(prog) <- i*2
}

Is there a way to explicitly rerender a tcltk toplevel? There must be
one since the ProgressBar widget causes this to happen, or am I wrong?
Or is there another way I could make this work?
Hope someone can help me here,

Florian

PS:
sessionInfo()
Version 2.3.0 Under development (unstable) (2006-02-20 r37405)
x86_64-unknown-linux-gnu

attached base packages:
 [1] "grid"      "tools"     "tcltk"     "stats"     "graphics"  "grDevices"
 [7] "utils"     "datasets"  "methods"   "base"

other attached packages:
       prada RColorBrewer      Biobase
     "1.9.2"      "0.2-3"     "1.9.18"


-- 
Florian Hahne
Abt. Molekulare Genomanalyse (B050)
Deutsches Krebsforschungszentrum (DKFZ)
Im Neuenheimer Feld 580
D-69120 Heidelberg
phone: 0049 6221 424764
fax: 0049 6221 422399
web: www.dkfz.de/mga



More information about the R-devel mailing list