Learn R Programming

gWidgets (version 0.0-53)

ggenericwidget: A constructor to create widgets for evaluating functions

Description

This constructor creates a widget for collecting arguments for a function using a list to define the widget's components. When called with a function name a list is created on the fly which can be used as is, or modified as desired.

Usage

ggenericwidget(lst,  cli = NULL, container = NULL, ..., toolkit = guiToolkit())

Arguments

lst
Either a list defining the widget or a function name as a string. In the latter case, the defining list may be retrieved by the svalue method.
cli
An instance of gcommandline or NULL. If NULL, then a new command line pops up in its own window
container
Optional container to attach widget to
...
Currently ignored by ggenericwidget, but passed along to gedit by geditlist and geditnamedlist
toolkit
Which GUI toolkit to use

Details

This widget provides an easy way to create dialogs that collect the arguments for a function evaluation. When the OK button is clicked, the arguments are collected and passed along to the function specified via the action part of the list. When collecting the arguments, empty strings are not passed along.

The easiest usage is to simply provide a function name and have autogenerategeneric take a stab. However, in the long run it might be better to use autogenerategeneric to create an initial list, and then modify this to adjust the widget's look.

The list contains several named components [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

The svalue method returns the value of the list. This can be used to retrieve the list that is created when the constructor is called with a function name.

Examples

Run this code
## a sample list definition
## Save some typing by defining a list to be used more than once later
TRUE.list <- list(
  type = "gradio",
  items = c("TRUE","FALSE")
  )

## define a list for producing a histogram widget	  
hist.list <- list(
  title = "hist()",
  help = "hist",
  action = list(
    beginning = "hist(",
    ending = ")"
    ),
  type = "graphic",                      # either text or graphic
  variableType = "univariate",           # single variable
  arguments = list(
    adjustments = list(
      breaks= list(
        type="gdroplist",
        items=c("\"Sturges\"","\"Scott\"","\"Friedman-Diaconis\"")
        ),
      probability = TRUE.list,
      include.lowest = TRUE.list,
      right = TRUE.list,
      shading = list(
        density = list(
            type="gedit",
            text=NULL
        ),
      angle = list(
        type="gedit",
        coerce.with="as.numeric",
        text="45"
        )
        )
      )
    )
  )

ggenericwidget(hist.list, container=TRUE)
## or to autogenerate one
ggenericwidget("boxplot.default", container=TRUE)

Run the code above in your browser using DataLab