[BioC] Tcl/tk command - checkbutton problem

Keith Satterley keith at wehi.edu.au
Tue Oct 11 03:39:39 CEST 2005


Try James Wettenhall's R TclTk Examples at

In particular, radio buttons are described here and check boxes are also 

  Radio buttons in R TclTk at

The following example illustrates the use of radio buttons in a tk 
toplevel window. The choice of radiobutton is mapped to a Tcl variable 
called rbValue, which is initialized to "oranges", which is the value of 
the second radio button (i.e. initially, the second radio button will be 
selected). The OnOK function triggered by the OK button captures the 
value of the Tcl variable mapped to the radiobuttons (rbValue) before 
destroying the window. Then it displays an appropriate message box 
depending on the choice of radiobutton.

tt <- tktoplevel()
rb1 <- tkradiobutton(tt)
rb2 <- tkradiobutton(tt)
rbValue <- tclVar("oranges")
tkgrid(tklabel(tt,text="Which do you prefer?"))
tkgrid(tklabel(tt,text="Apples "),rb1)
tkgrid(tklabel(tt,text="Oranges "),rb2)

OnOK <- function()
    rbVal <- as.character(tclvalue(rbValue))
    if (rbVal=="apples")
    	tkmessageBox(message="Good choice!  An apple a day keeps the doctor away!")
    if (rbVal=="oranges")
    	tkmessageBox(message="Good choice!  Oranges are full of Vitamin C!")
OK.but <- tkbutton(tt,text="OK",command=OnOK)

There are lots of other examples as well,


Keith Satterley,
Bioinformatics and Genetics,
The Walter and Eliza Hall Institute of Medical Research,
Melbourne, Victoria, Australia.

Sebastian Różewicz wrote:

>I need help with tk/tcl command - with checkbutton... How can I get 
>status of the checkbutton. I need to know if the checkbutton is selected 
>or not. And I need to have this information in a new variable.
>Please for examples if sombody know how to do it
>Daj sie skusic... >>> http://link.interia.pl/f18bc
>Bioconductor mailing list
>Bioconductor at stat.math.ethz.ch

More information about the Bioconductor mailing list