[R] re trieve user input from an tcl/tk interface

jverzani jverzani at gmail.com
Tue Sep 29 04:01:14 CEST 2009


einsundeins <floriansense <at> gmail.com> writes:

> 
> 
> Hello everyone,
> 
> this is my first post here and I hope I signed up correctly and someone will
> take me by the hand and help me out. I am new to R and cannot figure out
> what to do here...
> 
> ... I want to have an User Interface that requests input. I want to save
> this input to a variable to use it later on. I was able to do this with a
> modalDiaglog (
> http://bioinf.wehi.edu.au/~wettenhall/RTclTkExamples/modalDialog.html like
> this ) but I cannot figure out how to do this with multiple values to be
> read.
> 
> I want to run a rather simple simulation and the user has to be able to set
> multiple parameters (say, number of trials and stimuli). The onOK-function
> should then "collect" these parameters and save them to variables (I guess). 
> 

Dear Florian, you may want to look at the gWidgetstcltk package which makes such
things a bit easier than plain tcltk. Here is one way with a modal dialog:

f <- function() {
  library(gWidgets)
  options("guiToolkit"="tcltk")
  dlg <- gbasicdialog()
  tbl <- glayout(cont = dlg)
  tbl[1,1] <- "trials"
  tbl[1,2] <- (trials <- gedit("100", coerce.with=as.numeric, cont = tbl))
  tbl[2,1] <- "Stimuli"
  tbl[2,2] <- (stimuli <- gedit(10, coerce.with=as.numeric, cont = tbl))
  visible(dlg, set=TRUE)

  return(sapply(list(trials, stimuli), svalue))
}


> 
> Best regards,
> Florian




More information about the R-help mailing list