Re: Using foreach loop to create radiobutton menu
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: Using foreach loop to create radiobutton menu

From: Uwe Klein <uwe_klein_habertwedt@t-online.de>
Date: Fri Apr 28 2006 - 19:07:42 CEST

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
Received on Sun Apr 30 03:30:51 2006