Question

How do you create your status line at the bottom of your window? An inactive entry does not look very nice. What other options are there?

Is possible to integrate a progress bar which is visible only on demand?

(I am using tk and ttk from within R.)

EDIT: Now here is my second version, which works fine for me, but I would like to display the whole status bar on demand only (similar to what the status bar in the Chrome browser does). How can I do that? Calling tklower(f) does not help...

library(tcltk)
library(tcltk2)
tkdestroy(root)
root <- tktoplevel()
status <- tclVar("")
progress <- tclVar("0")
b <- tk2button(root, text="fake doing something!")
tkpack(b, padx=40, pady=10)
o <- tk2checkbutton(root, text="show progress", variable=progress)
tkpack(o, pady=10)

f <- tk2frame(root, relief="sunken")
l <- tk2label(f, textvariable=status)
tkpack(l, side="left", pady=2, padx=5, expand=0, fill="x")
tkpack(f, side="left", expand=1, fill="x", anchor="s")

sg <- ttksizegrip(root)
tkpack(sg, side="left", expand=0, anchor="se")

doit <- function() {
    tclvalue(status) <- "working (hard) ..."
    tcl("update")
    do.pb <- tclvalue(progress)=="1"
    if(do.pb) {
        pb <- tk2progress(f, length=60, mode="determinate")
        tkpack(pb, side="right", expand=0, padx=3, pady=2)        
        tkconfigure(pb, maximum=100, value=0)
    }
    for(i in 1:100) {
        if(do.pb) {
            tkconfigure(pb, value=i)
            tcl("update")
        }
        Sys.sleep(0.03)
    }
    if(do.pb) tkdestroy(pb)
    tclvalue(status) <- "Ready."
}
tkconfigure(b, command=doit)

tclvalue(status) <- "Ready."
Was it helpful?

Solution

I use a ttk::frame widget. In that I'll place one or more ttk::label widgets, and a ttk::sizegrip widget on the far right.

As for the progress bar -- just add it as usual. If you use grid, you can use grid remove to remove it from the statusbar but grid will remember its settings so you can add it right back. Or, you can user lower and raise to remove it from view and bring it back again.

Your question about the sizegrip widget is unclear. What about it doesn't work for you on windows?

OTHER TIPS

By status line do you mean like the status bar you find at the bottom of most browser windows? If so, I usually use a label with its textvariable linked to a variable containing the status string.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top