[R] Radio Buttons or similars

ermimi ermimi_ at hotmail.com
Thu Mar 20 00:50:27 CET 2008


Hello companions!!!

I have a function that creates a Radio Buttons, and I need that this
function return the selected value in the Radio Buttons. I would like that,
if somebody know as I could return the value, you say me as do it. 

Next, I show the function


function1<-function(){
	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)
	value<-0;
	aux_function<- 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!")
	    print(rbVal);
	    return(rbVal);
	}
	OK.but <- tkbutton(tt,text="OK",command=function() aux_function())
	#OK.but <- tkbutton(tt,text="OK",command=function() value<<-aux_function())
	
	tkgrid(OK.but)
	tkfocus(tt)
	#return(value)
	}




Thanks in advance!
A greetings Luismi
-- 
View this message in context: http://www.nabble.com/Radio-Buttons-or-similars-tp16164495p16164495.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list