title: How to bind a ListBox to the Return Key in order to close the window
body: <p>This seems like a fairly straightforward problem but I cannot get to solve it. When the following code is run, the first window comes with two entry boxes. When we use 'TAB' key, the second entry box will pop out a window from which a value needs to be selected from a ListBox. I have coded the part where the value in the ListBox needs to come into the entry box of the first window, however, I am unable to get the second window to close once the selection is made.</p>
  
  <pre><code>from Tkinter import *
  
  def fn_jump(event=None):
  
  
  
      def listbox_update(data):
          # delete previous data
          listbox.delete(0, 'end')
  
          # put new data
          for item in data:
              listbox.insert('end', item)
  
      def on_select(event):
          # display element selected on list
          print('(event) previous:', event.widget.get('active'))
          print('(event)  current:', event.widget.get(event.widget.curselection()))
          a = (event.widget.get(event.widget.curselection()))
          print a
          txtbox2.delete(0, END)
          txtbox2.insert(0,a)
          #listbox.bind('&lt;&lt;Return&gt;&gt;', window3.quit())   #This is not working
  
  
  
      window3 = Toplevel()
      window3.title("This window popped out")
      window3.geometry('{}x{}'.format(500,200))
  
  
  
      listbox = Listbox(window3, width=60)
      listbox.grid(row=0)
  
      listbox.bind('&lt;&lt;ListboxSelect&gt;&gt;', on_select)
  
  
      test_list = ('apple', 'banana', 'Cranberry', 'dogwood', 'alpha', 'Acorn', 'Anise', 'Strawberry')
  
      listbox_update(test_list)
  
  
  root = Tk()
  txtbox1 = Entry(root)
  txtbox2 = Entry(root)
  
  txtbox1.grid(row=0)
  txtbox2.grid(row=1)
  
  txtbox2.bind('&lt;KeyRelease&gt;', fn_jump)
  
  
  root.mainloop()
  </code></pre>