listbox binding..what is the current selection?

Rick Johnson rantingrickjohnson at
Wed Mar 6 02:26:12 CET 2013

On Tuesday, March 5, 2013 6:54:45 PM UTC-6, Rex Macey wrote:
> I have a listbox with two strings "Fixed" and "Random".
> [...] Here's the beginning of the set_lengthtype code:
> def set_lengthtype(event=None): 
>    s=lbLengthtype.get(tk.ACTIVE)
>    print(s)  
>    .....
> The print(s) statement is for debugging.  If 'Random' was
> selected and the user clicks 'Fixed',  then Random will
> print.  I would like to know what the user just selected,
> not what was selected before the user clicked.  How can I
> determine the current selection? Thanks.

Use "listbox.nearest(event.y)" instead of "get(ACTIVE"). And maybe you should spend some time reading the docs eh?

More information about the Python-list mailing list