[R] Dropdown boxes in tcltk and R

From: jake <jake_at_fantasticteam.com>
Date: Sun, 13 May 2007 15:49:16 +0100


I'm very much a newbie in R and more so in tcltk so apologies if this question is stupid. Basically I am trying to use the combobox example found here:
http://bioinf.wehi.edu.au/~wettenhall/RTclTkExamples/DropDown.html .

What I want to do is in that example get fruitChoice as a variable in R in general. When I run that code, however, and the ask for fruitChoice it says 'error not found'. I suspect it's because its embedded in a function, but I can't work out how to unravel it. I've tried something like this to no avail.

tt <- tktoplevel()
tkgrid(tklabel(tt,text="What's your favorite fruit?")) fruits <- c("Apple","Orange","Banana","Pear") comboBox <- tkwidget(tt,"ComboBox",editable=FALSE,values=fruits) tkgrid(comboBox)

OnOK <- function()

    msg <- paste("Good choice! ",fruitChoice,"s are delicious!",sep="")     tkmessageBox(title="Fruit Choice",message=msg)

OK.but <-tkbutton(tt,text=" OK ",command=OnOK) tkgrid(OK.but)


fruitChoice <- fruits[as.numeric(tclvalue(tcl(comboBox,"getvalue")))+1]


Which gives me:

Error in structure(.External("dotTclObjv", objv, PACKAGE = "tcltk"), class = "tclObj") :

        [tcl] invalid command name ".14.2".

What do I need to change to get the variable? That is, if I pick "orange", I want a variable with the value "orange".

Thanks for your reply, I'm sure this is something simple I've overlooked,


R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon 14 May 2007 - 09:51:21 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 14 May 2007 - 13:31:18 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.