tkProgressBar(title = "R progress bar", label = "",
min = 0, max = 1, initial = 0, width = 300)
getTkProgressBar(pb)
setTkProgressBar(pb, value, title = NULL, label = NULL)
## S3 method for class 'tkProgressBar'
close(con, ...)
Arguments
title, label
character strings, giving the window title and the
label on the dialog box respectively.
min, max
(finite) numeric values for the extremes of the
progress bar.
initial, value
initial or new value for the progress bar.
width
the width of the progress bar in pixels: the dialog box
will be 40 pixels wider (plus frame).
pb, con
an object of class "tkProgressBar".
...
for consistency with the generic.
Details
tkProgressBar will display a widget containing a label and
progress bar.
setTkProgessBar will update the value and for non-NULL
values, the title and label (provided there was one when the widget
was created). Missing (NA) and out-of-range values of
value will be (silently) ignored.
The progress bar should be closed when finished with.
This will use the ttk::progressbar widget for Tk version 8.5 or
later, otherwise R's copy of BWidget's progressbar.
Value
For tkProgressBar an object of class "tkProgressBar".
For getTkProgressBar and setTkProgressBar, a
length-one numeric vector giving the previous value (invisibly for
setTkProgressBar).
See Also
txtProgressBar
Examples
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)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(tcltk)
Error : .onLoad failed in loadNamespace() for 'tcltk', details:
call: fun(libname, pkgname)
error: Tcl/Tk support is not available on this system
In addition: Warning message:
S3 methods 'as.character.tclObj', 'as.character.tclVar', 'as.double.tclObj', 'as.integer.tclObj', 'as.logical.tclObj', 'as.raw.tclObj', 'print.tclObj', '[[.tclArray', '[[<-.tclArray', '$.tclArray', '$<-.tclArray', 'names.tclArray', 'names<-.tclArray', 'length.tclArray', 'length<-.tclArray', 'tclObj.tclVar', 'tclObj<-.tclVar', 'tclvalue.default', 'tclvalue.tclObj', 'tclvalue.tclVar', 'tclvalue<-.default', 'tclvalue<-.tclVar', 'close.tkProgressBar' were declared in NAMESPACE but not found
Error: package or namespace load failed for 'tcltk'
Execution halted