Below is an artificial example of a R widget
library(gWidgets)
options("guiToolkit"="RGtk2")
f <- function(file, max.rows){
dat <- read.table(file, nrows=max.rows)
return(max(dat[,]))
}
lst <- list()
lst$action <- list(beginning="f(",ending=")")
lst$arguments$file <- list(type="gfilebrowse")
lst$arguments$max.rows <- list(type="gedit", text=-1)
ggenericwidget(lst, container=gwindow("Example"))
The name of each argument in the R widget is the same as its name in the R function. Is it possible to only change the name appearing in the R widget ? For instance, I would like to write "Maximum number of rows" in the R widget instead of "max.rows".
All I could come up with was the following, working from this post. I'm not sure if you're willing to create the widgets from scratch, but it seems to me that it's the only way to manually choose labels for your arguments.
library(gWidgets)
options("guiToolkit"="RGtk2")
f <- function(file, max.rows){
dat <- read.table(file, nrows=max.rows)
return(max(dat[,]))
}
win <- gwindow("Example")
grp.text <- ggroup(horizontal=FALSE, container = win)
lbl.text <- glabel("Maximum Lines: ", container = grp.text)
insert.text <- gedit(-1, container = grp.text)
grp.file <- ggroup(horizontal=FALSE, container = win)
lbl.file <- glabel("File: ", container = grp.file)
browse.file <- gfilebrowse(container = grp.file)
read <- gbutton(text="Go", container = grp.file,
handler = function(h, ...) {
cat(f(svalue(browse.file),
as.numeric(svalue(insert.text))));
}
)
This is a minimal example; there would have to be some error-checking along the way.