Display a progress bar in an existing tcltk window with R -
my program contains main window in display progress bar. use tcltk , r.
the following code shows how display progress bar in new popped-up window, not want : want inside window precedently created.
pb <- tkprogressbar("test progress bar", "some information in %",0, 100, 50) sys.sleep(0.5) u <- c(0, sort(runif(20, 0, 100)), 100) for(i in u) { sys.sleep(0.1) info <- sprintf("%d%% done", round(i)) settkprogressbar(pb, i, sprintf("test (%s)", info), info) } sys.sleep(5) close(pb)
i've no idea how insert in window.
thank you
this pretty lifted this answer. gist tkprogressbar
won't want. instead, there's function tk2progress
in tcltk2
package. using function, can create widget can place in window.
root <- tktoplevel() l1 <- tk2label(root) pb1 <- tk2progress(root, length = 300) tkconfigure(pb1, value = 0, maximum = 9) tkgrid(l1, row = 0) tkgrid(pb1, row = 1) (index in 1:10){ tkconfigure(l1, text = paste("index", index)) tkconfigure(pb1, value = index - 1) sys.sleep(1) }
Comments
Post a Comment