anItemGroup: Constructor for ItemGroup instances

Description Usage Arguments Details Value See Also Examples

Description

An ItemGroup creates a model with properties given by the items and a default layout for its items. This can also be specified when the layout is drawn through make_gui.

Usage

1
anItemGroup(items = list(), name, ...)

Arguments

items

List of Item instances or ItemGroup instances

name

Name of ItemGroup.

...

Passed to ItemGroup proto trait

Details

An item group bundles a list of items into a model. When the model is intialized, constructors to access the model values are created. These getters/setters use the item names, so that get_name will get the main value for the item with name attribute "name".

An item group has the useful methods to_R to return the values in the model as a named list and get_item_by_name to get the item from the list of items matching the name.

Value

A proto object. Call obj$show_help() to view its methods and properties.

See Also

aContainer for specifying a layout

Examples

 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
## Not run: 
## make a simple item group, show in non-default layout
i <- anItemGroup(items=list(
                 numericItem(0,"x"),
                 numericItem(0,"y"),
                 stringItem("","z")
                 ))
lay <- aContainer("x","y", aFrame("z", label="z in a box"))
## some proto methods:
i$make_gui(cont=gwindow("Example of itemGroup"), gui_layout=lay)
i$get_x()     # get x value
i$set_x(10)   # set x value to 10
i$to_R()      # get list of x,y,z values

## End(Not run)

## example of using an item group and gbasicdialog to make a modal  GUI
ig <- anItemGroup(items=list(
                    x=numericItem(2)
                    )
                  )

## using gbasicdialog from gWidgets
## Not run: 
w <- gbasicdialog("testing", handler=function(h,...) {
  . <- h$action                         # action passes in itemgroup
  .$output <- sin(.$get_x())
},
                  action=ig)
ig$make_gui(container=w)
visible(w, TRUE)  ## modal now
print(ig$output)

## End(Not run)

traitr documentation built on May 2, 2019, 3:32 p.m.