Description Usage Arguments Details See Also Examples
View source: R/gcheckboxgroup.R
Widgets to select one (or several) from a given vector of items. These are a radio group where all values are shown at once, but only one may be selected; a checkbox group where more than one may be selected; and a combo box (or droplist) where initially only a single value is shown, and the others are a mouse click away,
1 2 | gcheckboxgroup(items, checked = FALSE, horizontal = FALSE, use.table=FALSE,
handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit())
|
items |
Vector of values to select from |
checked |
A logical vector indicating initial values. |
horizontal |
A logical specifying the layout for gradio and gcheckboxgroup |
handler |
Called when selection is changed |
use.table |
If |
action |
Passed to handler when called. |
container |
Optional container to attach widget to |
... |
Passed to |
toolkit |
Which GUI toolkit to use |
The svalue
method returns the selected values by
name. If the extra argument index=TRUE
is specified,
the indices of the selected values is given.
The svalue<-
method can be used to set the selected
value. This widget is a cross between a checkbox and a radio
button group. As such, there are different ways to specify the
state. As with a checkbox, the argument can be a logical
vector indicating which checkboxes are to be checked
(recycling is done). As with a radio button group, the value
can be a character vector indicating by label which checkboxes
are to be checked; or if the index=TRUE
argument is
given, a vector of indices for those checkboxes to be checked.
The "["
method refers to the vector defining the items.
The "[<-"
method can be used to change the vector
defining the items. The length should be the same as the
original, although in some toolkits this isn't necessary.
The "length"
method returns the number of items.
A checkboxgroup is one of several ways to select a value of a set of items. See also
gcheckbox
,
gradio
,
gcombobox
, and
gtable
.
Methods for gComponent objects are detailed in gWidgets-methods
.
Event Handlers are detailed in gWidgets-handlers
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ## Not run:
flavors <- c("vanilla", "chocolate", "strawberry")
f <- function(h,...) print(
paste("Yum",
paste(svalue(h$obj),collapse=" and "),
sep = " "))
w <- gwindow("checkbox example")
gp <- ggroup(container=w)
glabel("Favorite flavors:",container=gp)
cbg <- gcheckboxgroup(flavors, container=gp, handler=f)
svalue(cbg) <- c(TRUE, FALSE, TRUE)
svalue(cbg)
svalue(cbg) <- "vanilla"
svalue(cbg, index=TRUE) <- 1:2
cbg[3] <- "raspberry"
## use a table to display (toolkit specific) so that scrollars can be used
cbg <- gcheckboxgroup(letters, container=gwindow(), use.table=TRUE)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.