gslider: Constructors for widgets to select a value from a sequence.

Description Usage Arguments Details Examples

View source: R/gslider.R

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

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())

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

Arguments

from

Starting point in range. For glider, this may be a vector of values that can be sorted from sort(unique(...)). In this case, to, by, etc. are ignored.

to

Ending point in range

by

Step size between values in the sequence

length.out

In place of by, take number of steps from this

along.with

In place of length.out, take length from this vector

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

Widgets to select from a vector of values. This vector is usually a sequence, as is returned by seq, hence the similar arguments, although the implementation is a bit less general, as length.out and along.with are used to compute by when given.

For gslider any ordered vector may be used if specified to from. Some toolkits only allow integer sequences, see the respective gWidgetsXXX packages for details.

The svalue method returns the selected value. If all values are specified to from, then index argument is respected.

The svalue<- method is used to set the selected value. If all values are specified to from, then index argument is respected.

The [<- method can be used to change the sequence that the value is selected from. It expects a regular sequence, or if all values were originally specified to from a sortable sequence.

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## 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(container=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,
    container = tbl, handler = plotHist))

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


  ## other sequence:
  w <- gwindow("Slider with sequence")
  sl <- gslider(letters, container=w)
  svalue(sl, index=TRUE)
  svalue(sl) <- "m"
  sl[] <- LETTERS ## can be sorted via sort(unique(LETTERS))

## End(Not run)

gWidgets documentation built on April 29, 2020, 9:37 a.m.