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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listbox bindings

Status
Not open for further replies.

splinter98

Programmer
Feb 27, 2005
2
GB
I want to be able to get a listbox select one of the options right-click it a menu pops up and then there is listed a load of commands in which the option selected is included as part of some of the labels i have this code:
Code:
frame .f
 listbox .lb -selectmode multiple -height 4
 scrollbar .sb -command [list .lb yview]
 .lb configure -yscrollcommand [list .sb set]
 .lb insert end sample
 pack .lb .sb -in .f -side left -expand 1 -fill both
set m [menu .popupMenu]
set sel [.lb curselection]
$m add command -label $sel -command bell
bind .lb <3> {tk_popup .popupMenu %X %Y}
grid .f

the menu works but all i get is a blank item. any suggestions wld be helpful
 
You set "sel" before the selection is made. I think you need to make the statements

set sel [.lb curselection]
$m add command -label $sel -command bell

part of the bind command.

Bob Rashkin
rrashkin@csc.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top