File: gradio.Rd

package info (click to toggle)
r-cran-gwidgets 0.0-54.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 2,360 kB
  • sloc: sh: 13; makefile: 2
file content (93 lines) | stat: -rw-r--r-- 2,617 bytes parent folder | download
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
\name{gradio}
\alias{gradio}
\alias{[<-,gRadio-method}
\title{Radio button group widget}
\description{

	A radio group allows the user to select one value from a set
	of items. The items may be displayed horizontally or
	vertically.

}
\usage{
gradio(items, selected = 1, horizontal = FALSE, handler
= NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit())
}


\arguments{
  \item{items}{ Vector of values to select from }
  \item{selected}{ The initial selected value (as an index). Radio groups must have a selection}
  \item{horizontal}{A logical specifying the  layout for gradio}
  \item{handler}{Called when selection is changed}
  \item{action}{Passed to handler when called.}
  \item{container}{Optional container to attach widget to}
  \item{\dots}{Passed to \code{add} method of container}
  \item{toolkit}{Which GUI toolkit to use}
}
\details{
	The \code{svalue} method returns the selected value by
	name. If the extra argument \code{index=TRUE} is specified,
	the index of the selected value is given. 


	The \code{svalue<-} method can be used to set the selected
	value. One can specify the value by name or by index if
	\code{index=TRUE} is specified.

	The \code{"["} method refers to the vector defining the items.

	The \code{"[<-"} method can be used to change the vector
	defining the items. 

	The \code{"length"} method returns the number of items.
	
}
% \value{}
% \references{}
% \author{}
% \note{}
\seealso{

The radio group is one of several widgets useful to selecting a value
or values from a set of items. See also \code{\link{gcheckbox}},
\code{\link{gcheckboxgroup}}, \code{\link{gcombobox}}, and
\code{\link{gtable}}

Methods for gComponent objects are detailed in \code{\link{gWidgets-methods}}.

Event Handlers are detailed in \code{\link{gWidgets-handlers}}.

}
\examples{
\dontrun{

  flavors <- c("vanilla", "chocolate", "strawberry")

  w <- gwindow("Radio example", visible=FALSE)
  gp <- ggroup(container=w)
  glabel("Favorite flavor:",container=gp, anchor=c(0,1))
  rb <- gradio(flavors, container=gp)
  addHandlerClicked(rb, handler=function(h,..) {
   cat(sprintf("You picked \%s\n", svalue(h$obj)))
  })
  visible(w) <- TRUE
  
  betterFlavors <- c("coffee", "mint chip")
  rb[] <- betterFlavors 
  rb[] <- c(betterFlavors, "chocolate") # some toolkits don't allow change of length
  
  rb[3] <- "mango sorbet" ## can change a label name

  ## set values
  svalue(rb) <- "coffee"  ## by name
  svalue(rb, index=TRUE) <- 1  ## by index

  ## get selected values
  svalue(rb)
  svalue(rb, index=TRUE)

}

}
\keyword{interface}% at least one, from doc/KEYWORDS