Tkinter listbox:get

V

vedran_dekovic

Hi,
I need help about Tkinter.I want,when somebody click on some item in
listbox,then
in new entry widget must write that item

Regards,
Vedran
 
H

Hendrik van Rooyen

| Hi,
| I need help about Tkinter.I want,when somebody click on some item in
| listbox,then
| in new entry widget must write that item
|
| Regards,
| Vedran

I have already covered the retrieval from the listbox in another thread.
You can set the entry box contents like this:

NameOfStringForEntryboxContents = StringVar()

Then in your definition of the Entry box, add in:

textvariable = NameOfStringForEntryboxContents

and when you have retreived the listbox entry:

NameOfStringForEntryboxContents.set(NameOfStringWithListboxStuff)

and it will appear in your entry field...

HTH
-Hendrik
 
H

Hendrik van Rooyen

| Hi,and sorry I forget tell you what I want exactly.
|
| My problem is
|
| example:
|
| when I write like you tell me:
|
| >>> idx=lb.curselection()
| >>> StringValue=lb.get(idx) <======= This


|
| ....THEN,ERROR IS:
|
| Traceback (most recent call last):
| File "<pyshell#18>", line 1, in -toplevel-
| StringValue=b.get(idx) <========== is not the same as this



| File "C:\Python24\lib\lib-tk\Tkinter.py", line 2432, in get
| return self.tk.call(self._w, 'get', first)
| TclError: bad listbox index "": must be active, anchor, end, @x,y, or a
| number
|
| ...which index I must write to listbox get just clicked row.
|
|
| THANKS!!!!!!!!
|

Just use the print statement to see what is going on - use :

print idx

after getting the idx with the curselection - it must be the number of the row
that
was clicked

- Hendrik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top