Tkinter: listbox navigation

Eric Brunel eric.brunel at pragmadev.com
Wed Nov 13 04:18:24 EST 2002


Tim Daneliuk wrote:

> I have looked high and low but cannot find an answer to:
> 
> When I give the listbox focus, I am able to navigate around it using the
> arrow keys. So, even if I have selected a particular item, I can move to
> other items *which is indicated by an underlining of the currently
> navigated item*.  So, at any moment in time, one item may be selected
> and another underlined.
> 
> Is there a way programmatically to force the underlining to a particular
> item?

Yep: use listbox.activate(index) and make sure your listbox keeps the 
keyboard focus (via focus_set I suppose...). To know where the active line 
is, use listbox.index(ACTIVE).

> I cannot seem to find a complete set of docs on the various methods
> and attributes of a listbox, so a pointer to this would also be
> appreciated.

The most complete set of docs you'll ever find is the tk documentation in 
your man pages if you're on Un*x, or @ http://www.tcl.tk/man
You'll have to know how to translate tcl commands to Python methods, but 
that's not the toughest part of the job, especially if you already know the 
basics of Tkinter.

HTH
-- 
- Eric Brunel <eric.brunel at pragmadev.com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com



More information about the Python-list mailing list