[BioC] Tcl/tk command - checkbutton problem

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


Sebastian,

Try James Wettenhall's R TclTk Examples at
http://bioinf.wehi.edu.au/~wettenhall/RTclTkExamples/

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


  Radio buttons in R TclTk at
  http://bioinf.wehi.edu.au/~wettenhall/RTclTkExamples/radiobuttons.html

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.

require(tcltk)
tt <- tktoplevel()
rb1 <- tkradiobutton(tt)
rb2 <- tkradiobutton(tt)
rbValue <- tclVar("oranges")
tkconfigure(rb1,variable=rbValue,value="apples")
tkconfigure(rb2,variable=rbValue,value="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))
    tkdestroy(tt)
    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)
tkgrid(OK.but)
tkfocus(tt)

There are lots of other examples as well,

cheers,

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

Sebastian Różewicz wrote:

>Hi.
>
>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
>
>Thanks!
>Sebastian
>
>----------------------------------------------------------------------
>Daj sie skusic... >>> http://link.interia.pl/f18bc
>
>_______________________________________________
>Bioconductor mailing list
>Bioconductor at stat.math.ethz.ch
>https://stat.ethz.ch/mailman/listinfo/bioconductor
>  
>



More information about the Bioconductor mailing list