File: ex-gcheckbox.R

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 (72 lines) | stat: -rw-r--r-- 1,024 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
w <- gwindow("checkboxes", visible=FALSE)
g <- ggroup(cont = w, horizontal = FALSE)

## checkbox
cb <- gcheckbox("label", cont = g)

# svalue
print(svalue(cb))

# svalue<-
svalue(cb) <- FALSE


# [ (names)
print(cb[])

# [ (names<-)
cb[1] <- "new label"

# handler
addHandlerChanged(cb, function(h,...) print("clicked"))

## radio

r <- gradio(letters[1:3], cont = g, horizontal=TRUE)

# svalue
print(svalue(r))
print(svalue(r, index=TRUE))


#svalue<-
svalue(r) <- "b"
svalue(r,index = TRUE) <- 3

# [ -- names
print(r[])

# [<-
r[1] <- "A"
r[] <- c("A","B","C")

# handler
addHandlerChanged(r, handler = function(h,...) print("clicked radio"))

## gcheckboxgroup

cbg <- gcheckboxgroup(letters[1:3], cont = g)

## empty?
print(svalue(cbg))

## svalue<-
svalue(cbg) <- c(TRUE,TRUE, FALSE)

## svalue
print(svalue(cbg))
print(svalue(cbg, index=TRUE))

## names
print(cbg[])

## [<-
cbg[1] <- "A"
cbg[] <- c("A","B","C")

# handler
addHandlerChanged(cbg, handler = function(h,...) print(svalue(h$obj)))



visible(w) <- TRUE