[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-list
Subject:    Tkinter listbox:get
From:       Sorin Schwimmer <sxn02 () yahoo ! com>
Date:       2006-09-10 17:42:21
Message-ID: 20060910174221.31083.qmail () web56013 ! mail ! re3 ! yahoo ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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


[Attachment #5 (text/html)]

<html><head><style type="text/css"><!-- DIV {margin:0px} --></style></head><body><div \
style="font-family:times new roman, new york, times, serif;font-size:12pt"><div><span \
style="font-style: italic;">lb.curselection()</span> won't return an integer, but a tuple of \
strings. Also, a <span style="font-style: italic;">StringVar</span> receives a new value with \
the <span style="font-style: italic;">set()</span> method. So, you'll have to write something \
like:<br><br><span style="font-style: italic;">idx=lb.curselection()</span><br \
style="font-style: italic;"><span style="font-style: \
italic;">StringValue.set(lb.get(int(idx[0])))</span><br><br>This will grab the first value from \
the tuple, convert it in integer, and pass it to <span style="font-style: \
italic;">lb.get()</span> to extract the line in your <span style="font-style: \
italic;">Listbox</span>, and set it in your <span style="font-style: italic;">Entry</span> via \
the <span style="font-style: italic;">StringVar.</span> If  you allow multiple selections from \
your <span style="font-style: italic;">Listbox,</span> you may have more than one value in \
<span style="font-style: italic;">idx,</span> and you'll have to decide how you intend to \
process them.<br><br>Check any of these (or both):<br><span><a target="_blank" \
href="http://www.pythonware.com/library/tkinter/introduction/index.htm">http://www.pythonware.com/library/tkinter/introduction/index.htm</a></span><br><span><a \
target="_blank" href="http://infohost.nmt.edu/tcc/help/pubs/tkinter/">http://infohost.nmt.edu/tcc/help/pubs/tkinter/</a></span><br><br>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.<br><br>Good luck!<br>Sorin<br></div></div></body></html>



-- 
http://mail.python.org/mailman/listinfo/python-list

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic