Learn R Programming

gWidgets (version 0.0-25)

ggroup: Containers for packing in subsequent widgets

Description

A ggroup is the primary container for packing in subsequent widgets, either from left to right or top to bottom. Widgets are packed in using the add method and can be removed with the delete method.

The gframe and gexpandgroup widgets add a label to the group and in the latter case an arrow for hiding/showing the group.

Usage

ggroup(horizontal = TRUE, spacing = 5,  use.scrollwindow = FALSE, container = NULL, ..., toolkit = guiToolkit())

gframe(text = "", markup = FALSE, pos = 0, horizontal=TRUE, container = NULL, ..., toolkit = guiToolkit()) gexpandgroup(text = "", markup = FALSE, horizontal=TRUE, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit())

Arguments

Details

The groups pack in widgets from either left to right (when horizontal=TRUE) or from top to bottom (when horizontal=FALSE).

The spacing value determines the number of pixels of padding between each widget. This can be set when the group is constructed, or later using svalue.

The svalue<- method can be used to adjust the border width. By default it is 2 pixels. To put space between just two widgets, the addSpace(obj, value, ...) method may be used where value is the number of pixels of padding between the just packed widget, and the next one to be packed.

Widgets are packed together like blocks. When packing from top to bottom, the width of each widget can either be the natural size of the widget (the default), or if the expand=TRUE argument is given to the add method the widget will expand to fill the possible space.

The addSpring(obj,...) method will push the just packed widget and the next-to-be packed widget as far apart as possible.

In gWidgetsRGtk2 a few arguments add to the container. The argument raise.on.dragmotion = TRUE will cause the group to jump to the foreground when a drag action crosses it. The argument use.scrollwindow = TRUE will put the group

Examples

Run this code
## basic group
  group = ggroup(horizontal=FALSE, container=gwindow())
  add(group, glabel("widget 1"))
  add(group, gbutton("widget 2"))

  ## nested groups
  group = ggroup(horizontal=FALSE, container=gwindow())
  innergroup = ggroup(container = group)
  add(innergroup, gbutton("button 1"))
  add(innergroup, gbutton("button 2"))
  add(group, gtext("Text area"))

  ## expand argument
  group = ggroup(horizontal=FALSE, container=gwindow())
  add(group,gbutton("no expand"))
  add(group,gbutton("expand=TRUE"), expand=TRUE)

  ## add spring
  group = ggroup(container=gwindow("menubar-like example"))
  add(group, glabel("File",handler=function(h,...) print("file")))
  add(group, glabel("Edit",handler=function(h,...) print("edit")))
addSpring(group)				   
  add(group, glabel("Help",handler=function(h,...) print("help")))

Run the code above in your browser using DataLab