Tkinter listbox:get

Sorin Schwimmer sxn02 at yahoo.com
Sun Sep 10 13:42:21 EDT 2006


lb.curselection() won't return an integer, but a tuple of strings. Also, a StringVar receives a new value with the set() method. So, you'll have to write something like:

idx=lb.curselection()
StringValue.set(lb.get(int(idx[0])))

This will grab the first value from the tuple, convert it in integer, and pass it to lb.get() to extract the line in your Listbox, and set it in your Entry via the StringVar. If you allow multiple selections from your Listbox, you may have more than one value in idx, and you'll have to decide how you intend to process them.

Check any of these (or both):
http://www.pythonware.com/library/tkinter/introduction/index.htm
http://infohost.nmt.edu/tcc/help/pubs/tkinter/

They're both easy to follow, and you'll save more time, than asking one little think at a time, and then waiting for someone to answer.

Good luck!
Sorin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060910/50302b5f/attachment.html>


More information about the Python-list mailing list