Re: [R] Radio Buttons or similars

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Wed, 19 Mar 2008 21:09:40 -0400

Just one other item. See:
http://www.sciviews.org/_rgui/tcltk

You can probably answer most of these questions yourself if you find the right example there.

On Wed, Mar 19, 2008 at 9:07 PM, Gabor Grothendieck <ggrothendieck_at_gmail.com> wrote:
> Sorry, also uncomment your commented lines so its like this:
>
>
> 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;
> done <- tclVar(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!")
> tclvalue(done) <- 1 ###
> 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)
> tkwait.variable(done) ###
> tkdestroy(tt)
> return(value)
> }
>
>
>
>
> On Wed, Mar 19, 2008 at 9:04 PM, Gabor Grothendieck
> <ggrothendieck_at_gmail.com> wrote:
> > Use tkwait.variable(done) to wait until tcl variable done turns non zero.
> > I've changed the lines marked ###. Also see:
> > http://bioinf.wehi.edu.au/~wettenhall/RTclTkExamples/OKCancelDialog.html
> >
> > 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;
> > done <- tclVar(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!")
> > tclvalue(done) <- 1 ###
> > 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)
> > tkwait.variable(done) ###
> > tkdestroy(tt) ###
> > #return(value)
> >
> > }
> >
> >
> >
> > On Wed, Mar 19, 2008 at 7:50 PM, ermimi <ermimi__at_hotmail.com> wrote:
> > >
> > > 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.
> > >
> > > ______________________________________________
> > > R-help_at_r-project.org 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.
> > >
> >
>



R-help_at_r-project.org 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. Received on Thu 20 Mar 2008 - 01:25:50 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 20 Mar 2008 - 02:30:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive