listbox binding..what is the current selection?

Rex Macey xer0925 at gmail.com
Wed Mar 6 23:38:22 EST 2013


Thanks.  I have spent time with the docs, at least with the Python v3.3 and tkinter v8.5 (pdf).  I wish they had more examples. My approach is to browse the docs, try a program, fail, read the docs, try again.  When I can't figure it out, I post.  I appreciate the help.   


On Tuesday, March 5, 2013 8:26:12 PM UTC-5, Rick Johnson wrote:
> 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?
> 
> 
> 
>  http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/index.html



More information about the Python-list mailing list