Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

gcheckbox

constructor for checkbox widget


Description

A checkbox widget is used to toggle the state of a labeled boolean variable. The main property of this widget is that state, not the label. This variable may be proxied in the usual way – with a box that indicates or check if TRUE – or through a toggle button.

Generic for toolkit dispatch

The change handler for GCheckbox is called when the value toggles. You can inpsect the current value in the callback to have an action based on the state.

The object state is referred to by svalue as a logical (TRUE for checked). The svalue<- method ensures the value is a logical vector of length 1.

The item to select is referred to by the [ method, with only the first element being used.

Usage

gcheckbox(text = "", checked = FALSE, use.togglebutton = FALSE,
  handler = NULL, action = NULL, container = NULL, ...,
  toolkit = guiToolkit())

.gcheckbox(toolkit, text, checked = FALSE, use.togglebutton = FALSE,
  handler = NULL, action = NULL, container = NULL, ...)

## S3 method for class 'GCheckbox'
addHandlerChanged(obj, handler, action = NULL, ...)

## S3 replacement method for class 'GCheckbox'
 svalue(obj, index=NULL, ...) <- value

## S3 replacement method for class 'GCheckbox'
 x[i, j, ...] <- value

Arguments

text

label text

checked

is button selected

use.togglebutton

Use a toggle button (shows depressed) not a check box

handler

Callback called when toggle is changed.

action

passed to handler

container

parent container

...

passed to add method of container

toolkit

toolkit

obj

receiver object

index

ignored. Input is coerced to logical.

value

assignment value

x

checkbox object

i

item index

j

ignored

Value

Returns an object of class GCheckbox.

Note

The value is coerced to character, then only first element used for checkbox label

Examples

if(interactive()) {
  w <- gwindow("Selection widgets")
  g <- gvbox(cont=w)

  fl <- gformlayout(cont=g)
  gcheckbox("checkbox", checked=TRUE, cont=fl, label="checkbox")
  gradio(state.name[1:4], selected=2, horizontal=TRUE, cont=fl, label="gradio")
  gcheckboxgroup(state.name[1:4], horizontal=FALSE, cont=fl, label="checkbox group")

  bg <- ggroup(cont=g)
  gbutton("ok", cont=bg, handler=function(h,...) print(sapply(fl$children, svalue)))



}

gWidgets2

Rewrite of gWidgets API for Simplified GUI Construction

v1.0-8
GPL (>= 3)
Authors
John Verzani
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.