sengkannan
Technical User
- Jul 8, 2003
- 13
Hi I am trying to create a simple drop down menu which is created using a for loop. All the options are displayed but does not alow selection, it always picks last item on the list.
Please find short code bellow
Thanks Krish
#!/usr/bin/wish
menubutton .mb1 -text "appel" -menu .mb1.fruits
pack .mb1 -side left -fill y
set fruits(1) "appel"
set fruits(2) "pear"
set fruits(3) "orange"
set fruits(4) "grapes"
set fruits(5) "plums"
set m [menu .mb1.fruits -tearoff 0]
for {set i 1} {$i < 5} {incr i} {
$m add command -label $fruits($i) -command {.mb1 configure -text "$fruits($i)"}
}
Please find short code bellow
Thanks Krish
#!/usr/bin/wish
menubutton .mb1 -text "appel" -menu .mb1.fruits
pack .mb1 -side left -fill y
set fruits(1) "appel"
set fruits(2) "pear"
set fruits(3) "orange"
set fruits(4) "grapes"
set fruits(5) "plums"
set m [menu .mb1.fruits -tearoff 0]
for {set i 1} {$i < 5} {incr i} {
$m add command -label $fruits($i) -command {.mb1 configure -text "$fruits($i)"}
}