Learn R Programming

traitr (version 0.14)

anItemGroup: Constructor for ItemGroup instances

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

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

Arguments

items
List of Item instances or ItemGroup instances
name
Name of ItemGroup.
...
Passed to ItemGroup proto trait

Value

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

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.

See Also

aContainer for specifying a layout

Examples

Run this code
## 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)

Run the code above in your browser using DataLab