Tkinter listbox:get

Hendrik van Rooyen mail at microcorp.co.za
Sat Sep 9 04:41:19 EDT 2006


 <vedran_dekovic at yahoo.com> wrote in email:


| 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






More information about the Python-list mailing list