Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

a menubutton that display the name of its items

Status
Not open for further replies.

irenicus

Technical User
Jul 15, 2004
11
FR
I want to make a menubutton which display the name of the menu items selected I ve written :

Code:
set mylist [list BAGA DOLE FIAGAR GRASS GRENO LESIM LIMOG MONTP PALMA VENTO]

set myMenuButton [menubutton .myMenuButton  -menu .myMenuButton.myMenu -textvariable buttonName]
set buttonName  [lindex $radars 0]
set names [menu  .myMenuButton.myMenu]

foreach name $mylist {
    $names add command -label $name -command {set buttonName $name
    }
}
but only the last name of the list is display whatever the item I select
 
set mylist [list BAGA DOLE FIAGAR GRASS GRENO LESIM LIMOG MONTP PALMA VENTO]

set myMenuButton [menubutton .myMenuButton -menu .myMenuButton.myMenu -textvariable buttonName]
set buttonName [lindex $radars 0]
set names [menu .myMenuButton.myMenu]

foreach name $mylist {
$names add command -label $name -command "set buttonName $name
"
}

works very well
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top