miniGUI {miniGUI} | R Documentation |
Simple R GUI
Description
Function to create a simple Graphical User Interface based
on R\ functions based on tcltk
package.
Usage
miniGUI(mainFrameFun=evalPlugin,opFuns=NULL,title="mini GUI",
init=function(frm) {},WRAPFUN=TRUE)
evalPlugin(ev)
Arguments
mainFrameFun |
A function to display (params are labels and entry fields) in the main GUI window. |
opFuns |
Named list of functions to add in the GUI menu Ops. |
title |
Main window GUI title. |
init |
Function to call before the GUI setup. |
WRAPFUN |
when TRUE, the default option, an automatic
|
ev |
Expression to evaluate. |
Details
miniGUI
pops up a tcltk
window widget with a menu
bar containing two menus named Basics and Ops from which
different functionality may be addressed during a miniGUI
session.
The menu Basics is used to request general purpose task during
the session (like quitting), while Ops is usually where
more specific tasks, those the GUI is devoted to and that are given
in opFuns
are grouped. When a menu item from Ops is
selected a new window widget pops us reflecting all the parameters
the function selected has, so that the user can fill text entries or
set up the value for such parameters.
{init}
can be used to add initialization and checking
commands to the GUI. This function is executed before any other
command.
When WRAPFUN
is FALSE
no tcltk
widget
is created for the functions in opFuns
, allowing them to
build their own widget. Do not use it unless functions encode
its own tcltk, having into account the internals of the
package to setup in a proper way the GUI for that specific function.
Value
miniGUI
function returns nothing. Nevertheless, the results of
the execution of the different functions called during the miniGUI
session are available by means of the getMiniGUIans
function, and
also by means of the GUI ans. entry in the menu Basics.
Author(s)
Jorge Luis Ojeda Cabrera (jojeda@unizar.es).
See Also
miniGUI
, makeWidgetCmd
,
tcltk
.
Examples
require(tcltk)
##
## a simple example
##
fs <- list(
f=function(a=1) {cat("--f--");paste("f(a)=",a)},
g=function(a=1,b=rnorm) {cat("--g--");paste("g(a,b)=",a+b(a))},
h=function(a=1,b=3,c=3) {cat("--h--");paste("h(a,b,c)=",a+b+c)}
)
## evalPlugin is provided by the package
miniGUI(evalPlugin,opFuns=fs)
##
## an example with lm and glm functions
##
## create some data(in the global environment)
n <- 100
d <- data.frame(x=runif(n))
d$z <- 0.5 * rnorm(n)
d$y <- 2 * d$x + d$z
## makes a wrapper to access t.test
myTtest <- function(x,y,mu=0) return( t.test(x=x,y=y,mu=mu) )
## call miniGUI with myTtest, lm and glm functions
miniGUI(evalPlugin,opFuns=list("T test"=myTtest,"Lin. Mod."=lm,glm=glm))
## try menu "T test" only setting up x
##
## an example with WRAPFUN set to FALSE
##
gfs <- list()
for(i in names(fs))
{
## create GUI for fs[[i]] using miniGUIBase
gfs[[i]] <- makeWidgetCmd(i,fs[[i]],miniGUIBase)
}
miniGUI(evalPlugin,opFuns=gfs,WRAPFUN=FALSE)