[R-gui] Combination of menu and checkbox
Alberto Vieira Ferreira Monteiro
albmont at centroin.com.br
Wed Oct 24 03:56:27 CEST 2007
I am trying to combine the example of tkmenu...
http://bioinf.wehi.edu.au/~wettenhall/RTclTkExamples/menus.html
... with the example of checkbox...
http://bioinf.wehi.edu.au/~wettenhall/RTclTkExamples/checkboxes.html
... but without success.
What is my mistake? The code runs, but nothing is displayed if I click in
"The Checkbox":
require(tcltk)
mw <- tktoplevel()
mb <- tkmenu(mw)
tkconfigure(mw, menu=mb)
tt <- tkmenu(mb)
cb <- tkcheckbutton(tt)
cbValue <- tclVar("0")
tkconfigure(cb,variable=cbValue)
tkgrid(tklabel(tt,text="I like R TclTk "),cb)
OnOK <- function()
{
cbVal <- as.character(tclvalue(cbValue))
tkdestroy(tt)
if (cbVal=="1")
tkmessageBox(message="So do I!")
if (cbVal=="0")
tkmessageBox(message="You forgot to check the box to say that you like
R TclTk!",icon="warning")
}
OK.but <- tkbutton(tt,text="OK",command=OnOK)
tkgrid(OK.but)
tkadd(mb, "cascade", label = "The Checkbox", menu = tt)
tkfocus(mw)
Alberto Monteiro
More information about the R-SIG-GUI
mailing list