rpanel (version 1.1-4)

rp.doublebutton: Double-button widget for rpanel

Description

Adds a control with '+' and '-' buttons, to increment and decrement a variable.

Usage

rp.doublebutton(panel, variable, step, title=deparse(substitute(variable)),
                action=I, initval=NULL, range=c(NA, NA), log=FALSE,
                showvalue=FALSE, showvaluewidth=4, repeatinterval=100,
                repeatdelay=100, pos=NULL, foreground=NULL, 
                background=NULL, font=NULL, parentname=deparse(substitute(panel)),
                name=paste("doublebutton", .nc(), sep=""), ...)

Arguments

panel

the panel in which the doublebutton should appear.

variable

the name of the variable within the panel that the doublebutton should control.

step

the value by which the variable "variable" is incremented or decremented on pressing a button. When log is TRUE this is a factor instead.

title

the label for the doublebutton. This defaults to the name of var.

action

the function which is called when a button is pressed.

initval

the initial value for var (optional). The initial value can also be specified in the call to rp.control.

range

a 2-element numeric vector containing lower and upper limits for var. Use NA for no limit (upper and/or lower).

log

a logical variable which determines whether the increment (step) is multiplicative or additive.

showvalue

a logical variable which determines whether the present value of "variable" is shown between the + and - buttons. This is forced to FALSE when log is TRUE.

showvaluewidth

defines the width of the shown value in characters.

repeatinterval

the interval between auto-repeats (milliseconds) when the button is held down.

repeatdelay

the time after which the button starts to auto-repeat (milliseconds).

pos

the layout instructions. Please see the rp.pos example and help for full details.

foreground

colour of the text

background

colour of the text background

font

font to be used

parentname

this specifies the widget inside which the doublebutton widget.

name

name assigned to the doublebutton; used for disposal etc

...

...

Value

If the argument panel is the panelname string, the same string is returned. If the panel object is used, the altered panel is assigned to both the calling level and panel's environment level.

Warning

The action function should return the panel. Without this assignment any widgets added or alterations made to panel parameters within the action function will be lost.

Note that setting log=TRUE and showvalue=TRUE is not allowed.

Details

action should be a function of one argument, which should be the panel. The panel can then be manipulated, and data stored in the panel may be used/modified, then the (optionally modified) panel must be returned.

See rp.grid for details of the grid layout system.

References

rpanel: Simple interactive controls for R functions using the tcltk package. Journal of Statistical Software, 17, issue 9.

See Also

rp.radiogroup,rp.control

Examples

Run this code
# NOT RUN {
   density.draw <- function(panel) {
     plot(density(panel$x, bw = panel$h))
     panel
     }
   panel <- rp.control(x = rnorm(50))
   rp.doublebutton(panel, var = h, step = 0.05, 
     title = "Density estimate", action = density.draw,
     range = c(0.1, 5), initval=1)
# }

Run the code above in your browser using DataLab