[R-gui] FW: TCLTK Radiobutton-Problem

Alexander Wurzer alexander.wurzer at fin4cast.com
Thu Jul 26 10:39:18 CEST 2007


Hi again,

in the meantime I found the mistake I made. "variable" had not the same
identifier.

Regards,
Alex

-----Original Message-----
From: Alexander Wurzer [mailto:alexander.wurzer at fin4cast.com] 
Sent: Thursday, 26. July 2007 09:06
To: (r-sig-gui at stat.math.ethz.ch)
Subject: TCLTK Radiobutton-Problem


Hi everybody,

I'm currently working on my first tcl-Interface and now I have troubles with
radiobuttons. Everything works fine with a static set of radiobuttons. But I
need a dynamic solution. 

Here is a simplified example what I mean:

# static solution works fine
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)

# troubles with dynamic version 
require(tcltk)
tt <- tktoplevel()
fruits=c("Apple","Orange","Banana")
tkgrid(tklabel(tt,text="Which do you prefer?"))
myenv <<- new.env() # I thought this help, but it doesn't change anything...

for(i in 1:length(fruits))
{  eval(parse(text=paste("rb",i,"=tkradiobutton(tt)",sep="")),env=myenv)
   rbValue <- tclVar("Orange")
 
eval(parse(text=paste("tkconfigure(rb",i,",variable=rbValue,value=fruits[i])
",sep="")),env=myenv)
 
eval(parse(text=paste("tkgrid(tklabel(tt,text=fruits[i]),rb",i,")",sep="")),
env=myenv)
}
tkfocus(tt)

The Problem is, that in the dynamic version each radiobutton can be selected
and I don't know why.

Has anybody an idea what to do to solve this problem?

Many thanks for your support!

Regards,
Alex



More information about the R-SIG-GUI mailing list