This is safest if the below code is wrapped in another function. At the top level function (or whatever level you will be using your choice information at) first create the variable named choice with a default value (choice <- "").
In your OnOk function, change "choice<-" to "choice<<-", this will make the function change the value of the previously created variable, rather than create a local variable (which goes away before you do anything with it). Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] 801.408.8111 > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > project.org] On Behalf Of thoeb > Sent: Sunday, November 23, 2008 12:18 PM > To: r-help@r-project.org > Subject: [R] tklistbox - R-Objekt > > > Hello, I have a problem with a tklistbox. The user should be able to > choose > one out of two calculation methods needed for further calculations. My > r-script for that purpose looks like that: > > require(tcltk) > tt<-tktoplevel() > tl<-tklistbox(tt,height=4,selectmode="single",background="white") > tkgrid(tklabel(tt,text="select method for LAI calculation")) > tkgrid(tl) > method<- c("method1","method2") > for (i in (1:2)){ > tkinsert(tl,"end",method[i]) > } > tkselection.set(tl,0) > OnOK <- function(){ > choice<-method[as.numeric(tkcurselection(tl))+1] > tkdestroy(tt) > } > OK.but <-tkbutton(tt,text=" OK ",command=OnOK) > tkbind(tkgrid, "<Return>",OnOK) > tkgrid(OK.but) > > The function works, but it does not create any r-object to that I can > access > later on. How do I have to modify the function that I get an object > with the > value "method1" or "method2"? > > ----- > Tamara Hoebinger > University of Vienna > -- > View this message in context: http://www.nabble.com/tklistbox---R- > Objekt-tp20649714p20649714.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@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@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.