gtimer: Basic timer widget

Description Usage Arguments Examples

View source: R/gtimer.R

Description

Calls FUN every ms/1000 seconds. A timer is stopped through its stop_timer method which is called using OO style: obj$stop_timer().

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
gtimer(
  ms,
  FUN,
  data = NULL,
  one.shot = FALSE,
  start = TRUE,
  toolkit = guiToolkit()
)

.gtimer(toolkit, ms, FUN, data = NULL, one.shot = FALSE, start = TRUE)

Arguments

ms

interval in milliseconds

FUN

FUnction to call. Has one argument, data passed in

data

passed to function

one.shot

logical. If TRUE, called just once, else repeats

start

logical. If FALSE, started by start_timer OO method. (Call obj$start_time()).

toolkit

gui toolkit to dispatch into

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
i <- 0
FUN <- function(data) {i <<- i + 1; if(i > 10) a$stop_timer(); print(i)}
a <- gtimer(1000, FUN)
##
## a one shot timer is run only once
FUN <- function(data) message("Okay, I can breathe now")
hold_breath <- gtimer(1000*60, FUN, one.shot=TRUE)

## End(Not run)

gWidgets2 documentation built on Jan. 11, 2022, 1:07 a.m.