Learn R Programming

RSurvey (version 0.9.3)

ProgressBar: GUI: Progress Bar

Description

A progress bar that shows the status of long-running operations.

Usage

ProgressBar(win.title = "Progress Bar", label = "", maximum = 100,
  nsteps = NULL, min.nsteps = 10L, parent = NULL)

SetProgressBar(pb, value, label = NULL, step = NULL)

Arguments

win.title

character. String to display as the title of the dialog box.

label

character. String to display in the dialog box.

maximum

numeric. Maximum value for the progress bar. The minimum value is zero.

nsteps

numeric. Total number of increments the progress bar will make.

min.nsteps

numeric. Minimum number of increments. If greater than nsteps, the dialog box is not opened.

parent

tkwin. graphical user interface parent window

pb

ProgressBar. Object returned from ProgressBar, see ‘Value’ section.

value

numeric. Value for the progress bar, between zero and maximum.

step

numeric. Number of progress bar increments. If equal to nsteps, the dialog box will close.

Value

For ProgressBar an object of class "ProgressBar" and mode list is returned. Components of the list object include:

GetValue

function that returns the value of the progress bar.

MoveProgressBar

function that moves progress bar, passes a numeric argument.

SetLabel

function that sets label in the dialog box, passes a character argument.

DestroyWindow

function that closes the dialog box.

GetWindowState

function that returns false if the dialog box has been closed, otherwise true.

nsteps

see ‘Arguments’ section

For SetProgressBar, the previous value of the progress bar. An error is returned if the progress has terminated prematurely.

References

The code in this function was derived from the tkProgressBar function, version v3.0.2.

Examples

Run this code
# NOT RUN {
  maximum <- 10
  label <- "Estimated time to completion is being calculated\u2026"
  pb <- ProgressBar(label = label, maximum = maximum, nsteps = maximum)

  for (i in seq_len(maximum)) {
    est.time <- system.time(Sys.sleep(1))["elapsed"] * (maximum - i)
    label <- paste("Estimated time to completion is", round(est.time), "secs")
    ans <- try(SetProgressBar(pb, value = i, label = label, step = i))
    if (inherits(ans, "try-error")) break
  }
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab