Set selection item for listbox
- From: Kevin Walzer <kw@xxxxxxxxxxxxxxx>
- Date: Wed, 31 Jan 2007 08:15:35 -0500
I want to search a listbox for a term and set the selection to that term:
listbox .l -listvariable foo
pack .l
set foo "John"
set listitem [list John Paul George Ringo]
foreach item $listitem {
.l insert end $item
}
..l selection set [lindex [lsearch -inline [.l get 0 end] "John"]]
This code returns this error:
Error in startup script: bad listbox index "John": must be active,
anchor, end, @x,y, or a number
while executing
".l selection set [lindex [lsearch -inline [.l get 0 end] "John"]]"
Can anyone point me in the right direction?
--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
.
- Follow-Ups:
- Re: Set selection item for listbox
- From: Gerald W. Lester
- Re: Set selection item for listbox
- Prev by Date: Re: Whats a good way to write GUI apps
- Next by Date: Re: TWAPI and NET SESSION
- Previous by thread: Re: Whats a good way to write GUI apps
- Next by thread: Re: Set selection item for listbox
- Index(es):
Relevant Pages
|