[Rd] rerender tcltk toplevel

Florian Hahne fhahne at gmx.de
Mon May 22 13:08:29 CEST 2006


Thanks Peter,
that's what I was looking for. Works like a charm now...
Florian

Peter Dalgaard schrieb:
> 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.
>
>   


-- 
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