Re: Using foreach loop to create radiobutton menu



Bryan Oakley wrote:

Ok, I didn't realize you were using Iwidgets. I haven't used iwidgets in years and it appears to have some odd features. For example, I had no idea you could have a "foreach" statement inside a "-menu" definition.

You can't.
::iwidgets::menubar does a [subst] in an [uplevel] on the value that is
supplied for the -menu option.

the way to go would be build the -menu argument
with foreach:

foreach rng 1 {
append menuarg "radiobutton $f.range -label \"$rng\" -command {puts hello} ;"
}
menubutton $f.range -text "VALUE" -menu $menuarg

or thereabouts.

++++++++++++++++++++++++++
i get this as error output:

Error in startup script: can't read "rng": no such variable
while executing
"subst {
menubutton $f.range -text "VALUE" -menu {
foreach rng 1 {
radiobutton $f.range -label "$rng" -command {puts hello}
}
}
}"


uwe
.


Quantcast