title: Get selected item in listbox and call another function storing the selected for it
body: <p>I have a canvas that calls <code>createCategoryMeny(x)</code> when it is clicked.</p>
  
  <p>This function just creates a <code>Toplevel()</code> window,</p>
  
  <pre><code>def createCategoryMenu(tableNumber):
  
      ##Not interesting below:
      categoryMenu = Toplevel()
      categoryMenu.title("Mesa numero: " + str(tableNumber))
      categoryMenu.geometry("400x400+100+100")
  
      categoryMenu.focus()
      categoryMenu.grab_set()
  
      Label(categoryMenu, text="Elegir categoria \n Mesa numero: " + str(tableNumber)).pack()
  
  
      ## RELEVANT CODE BELOW:
      listbox = Listbox(categoryMenu, width=50, height=len(info.listaCategorias))
      listbox.pack(pady=20)
  
      for item in info.listaCategorias:
          listbox.insert(END, item)
  
      listbox.selection_set(first=0)
  
      ##My attempt to solve it
      callback = lambda event, tag= "ThisShouldBeTheSelected!!": do(event, tag)
      listbox.bind("&lt;Double-Button-1&gt;", callback)
  </code></pre>
  
  <p>Then the do function:</p>
  
  <pre><code>def do(event, tag):
      print tag
  </code></pre>
  
  <p>This successfully prints `"ThisShouldBeTheSelected!!"``.</p>
  
  <p>And this is where I am utterly stuck.</p>
  
  <p>I cant get the double clicked element (the selected one).</p>
  
  <p>I want to pass it as <code>tag=</code>.</p>
  
  <p>I have tried:</p>
  
  <pre><code>listbox.curselection()
  </code></pre>
  
  <p>Which always prints <code>('0',)</code></p>
  
  <p>If I remove <code>listbox.selection_set(first=0)</code>, I only get this: <code>()</code></p>
  
  <p>So the questions are:</p>
  
  <ul>
  <li>How can I get the selected item (the double clicked one)</li>
  <li>(Not so important) Is it reasonable to pass it to the other function like I do?</li>
  </ul>
  
  <hr>
  
  <p>Note:</p>
  
  <p>I found <a href="http://tcl.sourceforge.net/faqs/tk/#listbox/curselection" rel="noreferrer">this</a>:</p>
  
  <blockquote>
    <p><b>8.5. Why doesn't .listbox curselection or selection get return the
    proper item when I make a button binding to my listbox?</b></p>
    
    <p>The best way to get the selected item during a button click event on a
    listbox is to use the following code:</p>
    
    <p>bind .listbox  { set item [%W get [%W nearest %y]] }</p>
    
    <p>This ensures that the item under the pointer is what will be returned
    as item. The reason .listbox curselection can fail is because the
    items in curselection are not set until the Listbox class binding
    triggers, which is after the instance bindings by defaults. This is
    the same reason for which selection get can fail, but it will also
    fail if you set the -exportselection option to 0.</p>
  </blockquote>
  
  <p>I'm not sure if it's helpful, I don't really understand what it is saying.</p>