Florian Hahne <fhahne at gmx.de> writes:
> 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
tcl("update") should do the trick. Notice that this is
"considered
harmful" by some, although I don't see much of an issue here. Possibly,
tcl("update", "idletasks") is safer.
--
O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907