Hi Jake,
Two things I noticed:
- Don't tkdestroy(tt) too soon, you use comboBox later.
- Don't use fruitChoice in OnOK if you only define it at the
very end of your program.
Here's your code with these two modifications.
Greets,
Jonne.
require(tcltk)
tclRequire("BWidget")
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()
{
fruitChoice <<-
fruits[as.numeric(tclvalue(tcl(comboBox,"getvalue")))+1]
msg <- paste("Good choice! ",fruitChoice,"s are delicious!",sep="")
tkmessageBox(title="Fruit Choice",message=msg)
tkdestroy(tt)
}
OK.but <-tkbutton(tt,text=" OK ",command=OnOK)
tkgrid(OK.but)
tkfocus(tt)
tkwait.window(tt)
fruitChoice
______________________________________________
[email protected] 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.