I agree with
ulis that the easiest way to do this is with an associated
-listvariable. But if you're using a version of Tcl before the introduction of
-listvariable (Tcl/Tk 8.3.0), you can instead retrieve the contents of the listbox with the
get operation and then do the search.
[tt]%
[ignore]pack [listbox .l][/ignore]
%
.l insert 0 First Second Third Fourth Fifth
%
.l get 0 end
First Second Third Fourth Fifth
%
[ignore]lsearch [.l get 0 end] "Third"[/ignore]
2[/tt]
But even in this situation (pre-8.3), if I were needing to do a "reverse-lookup" of listbox entries frequently, I'd create a "shadow variable" of the listbox contents rather than constantly executing the
get operation.
- Ken Jones, President, ken@avia-training.com
Avia Training and Consulting,
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax