gslider: slider widget constructor

Description Usage Arguments See Also Examples

View source: R/gslider.R View source: R/gslider.R

Description

A slider widgets allows a selection from a range of numeric values. The widget presents the user with a quick to adjust, but relatively difficult to adjust precisely way to to pick a number.

generic for toolkit dispatch

Usage

1
2
3
4
5
6
7
gslider(from = 0, to = 100, by = 1, length.out = NULL,
  along.with = NULL, value = from[1], horizontal = TRUE, handler = NULL,
  action = NULL, container = NULL, ..., toolkit = guiToolkit())

.gslider(toolkit, from = 0, to = 100, by = 1, value = from,
  horizontal = TRUE, handler = NULL, action = NULL, container = NULL,
  ...)

Arguments

from

If a number of length one then a starting point, in which case to, by are passed to seq. Otherwise a sequence of values for which sort(unique(from)) will order

to

ending point when from is starting point

by

step size if not specified by from

length.out

in place of by

along.with

in place of length.out

value

initial value

horizontal

Logical. Is separator drawn horizontally?

handler

A handler assigned to the default change signal. Handlers are called when some event triggers a widget to emit a signal. For each widget some default signal is assumed, and handlers may be assigned to that through addHandlerChanged or at construction time. Handlers are functions whose first argument, h in the documentation, is a list with atleast two components obj, referring to the object emitting the signal and action, which passes in user-specified data to parameterize the function call.

Handlers may also be added via addHandlerXXX methods for the widgets, where XXX indicates the signal, with a default signal mapped to addHandlerChanged (cf. addHandler for a listing). These methods pass back a handler ID that can be used with blockHandler and unblockHandler to suppress temporarily the calling of the handler.

action

User supplied data passed to the handler when it is called

container

A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.)

...

These values are passed to the add method of the parent container. Examples of values are expand, fill, and anchor, although they're not always supported by a given widget. For more details see add. Occasionally the variable arguments feature has been used to sneak in hidden arguments to toolkit implementations. For example, when using a widget as a menubar object one can specify a parent argument to pass in parent information, similar to how the argument is used with gaction and the dialogs.

toolkit

Each widget constructor is passed in the toolkit it will use. This is typically done using the default, which will lookup the toolkit through guiToolkit.

See Also

gspinbutton

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
if(interactive()) {
  ## a range widget uses either a slider or a linked spinbutton to select a value
  w <- gwindow("Range widget", visible=FALSE)
  g <- ggroup(cont=w, horizontal=TRUE)
  sl <- gslider(from=0, to=100, by=1, value=0, cont=g, expand=TRUE, fill="both")
  sp <- gspinbutton(from=0, to=100, by=1, value=0, cont=g)

  ## Two ways to do this:
  ##  addHandlerChanged(sl, function(...) svalue(sp) <- svalue(sl))
  ##  addHandlerChanged(sp, function(...) svalue(sl) <- svalue(sp))

  f <- function(h, ...) svalue(h$action) <- svalue(h$obj)
  addHandlerChanged(sl, f, action=sp)
  addHandlerChanged(sp, f, action=sl)
  
  visible(w) <- TRUE
}

Example output

Loading required package: digest

gWidgets2 documentation built on May 29, 2017, 9:20 p.m.