Python Tkinter - Listbox custom class to return index, but there is no index
<p>I am trying to build a Class around Tkinter listbox, while adding some application specific attributes to it. The idea is to be able to call a generic listbox which returns the index of the selected item in a list. Listbox finally works, but now I've got a problem with the return value:</p>

<p>according to the documentation,  function listbox.curselection() returns the index number of the selected item, however it doesn't - it returns the selected entry as a tuple.</p>

<p>Is there a method of listbox which returns the index of the selected item? Or do I have to search through my list again to find the index of the selected item?</p>

<pre><code>class AudiListbox():

  def __init__(self, i_root, i_list):
    self.root = i_root
    self.root.scrollbar = Scrollbar(self.root, orient=VERTICAL)
    self.root.listbox=Listbox(self.root)
    self.root.listbox.bind('&lt;&lt;ListboxSelect&gt;&gt;',self.CurSelect)
    self.root.listbox.place(x=1, y=1)
    self.root.scrollbar.config(command=self.root.listbox.yview)
    self.root.scrollbar.pack(side=RIGHT, fill=Y)
    self.root.listbox.pack(side=LEFT, fill=BOTH, expand=1)
    self.root.listbox.insert(END, "------")

    for items in i_list:
        self.root.listbox.insert(END,items)
        print items

  def CurSelect(self, a):
      value=self.root.listbox.curselection()
      print type(value)
</code></pre>

<p>I'd be grateful for comments.</p>