gslider {gWidgets} | R Documentation

## Constructors for widgets to select a value from a sequence.

### Description

The gslider widget and gspinbutton widget allow the user to select a value from a sequence using the mouse. In the slider case, a slider is dragged left or right (or up or down) to change the value. For a spin button a text box with arrows beside allow the user to scroll through the values by clicking the arrows.

Some toolkits only allow integer values for these.

### Usage

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

    gspinbutton (from = 0, to = 10, by = 1, value = from, digits = 0,
        handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit())

### Arguments

`from` | Starting point in range
`to` | Ending point in range
`by` | Step size between values in the sequence
`value` | The initial value
`digits` | The number of digits shown
`horizontal` | Specifies orientation of gslider widget
`handler` | Called on a change event.
`action` | Passed to handler
`container` | Optional container to attach widget to
`...` | Passed to `add` method of container
`toolkit` | Which GUI toolkit to use

### Details

The `svalue` method returns the selected value.

The `svalue<-` method is used to set the selected value.

The `[<-` method can be used to change the sequence that the value is selected from. It expects a regular sequence.

The `addhandlerchanged` handler is called when the widgets' value is changed.

### Examples

    ## Not run:
      x <- rnorm(100)

      ## our handler
      plotHist <- function(...)
        hist(x, col=gray(svalue(sb)), breaks = svalue(sl))

      w <- gwindow("Slider and spinbox example")
      tbl = glayout(cont=w)
      tbl[1,1] <- "Slide value to adjust shade"
      tbl[1,2] <- (sb <- gspinbutton(from=0,to=1,by=0.05,value=.5, container=tbl,
        handler=plotHist))
      tbl[2,1] <- "No. breaks"
      tbl[2,2, expand=TRUE] <- (sl <- gslider(from = 1, to= 100, by=1, value = 10,
        cont = tbl, handler = plotHist))

    ## update slider using [<-
      sl[] <- seq(2,50, by=2)
    ## End(Not run)

[Package gWidgets version 0.0-39 Index]