title: Can't close tkinter root window after modalPane closed
body: <p>I've cloned a class called <code>ListBoxChoice</code> found on the web found (adding some needed features) below:</p>
  
  <pre><code>from Tkinter import *
  
  class ListBoxChoice(object):
      def __init__(self, master=None, title=None, message=None,\
                   list=[]):
      self.master = master
      self.value = None
      self.list = list[:]
  
      self.modalPane = Toplevel(self.master)
  
      self.modalPane.transient(self.master)
      self.modalPane.grab_set()
  
      self.modalPane.bind("&lt;Return&gt;", self._choose)
      self.modalPane.bind("&lt;Escape&gt;", self._cancel)
  
      if title:
          self.modalPane.title(title)
  
      if message:
          Label(self.modalPane, text=message).pack(padx=5, pady=5)
  
      listFrame = Frame(self.modalPane)
      listFrame.pack(side=TOP, padx=5, pady=5)
  
      scrollBar = Scrollbar(listFrame)
      scrollBar.pack(side=RIGHT, fill=Y)
  
      # get the largest value of the 'list' to set the width
      widthOfList = 0
      for k in list:
          if len(str(k)) &gt; widthOfList:
              widthOfList = len(str(k))
  
      # now pad some space to back of the widthOfList
      widthOfList = widthOfList + 2
  
      self.listBox = Listbox(listFrame, selectmode=SINGLE,\
                     width=widthOfList)
  
      self.listBox.pack(side=LEFT, fill=Y)
      scrollBar.config(command=self.listBox.yview)
  
      self.listBox.config(yscrollcommand=scrollBar.set)
      self.list.sort()
  
      for item in self.list:
          self.listBox.insert(END, item)
  
      buttonFrame = Frame(self.modalPane)
      buttonFrame.pack(side=BOTTOM)
  
      chooseButton = Button(buttonFrame, text="Choose",\
                     command=self._choose)
      chooseButton.pack()
  
      cancelButton = Button(buttonFrame, text="Cancel",\
                     command=self._cancel)
      cancelButton.pack(side=RIGHT)
  
      def _choose(self, event=None):
          try:
              firstIndex = self.listBox.curselection()[0]
              self.value = self.list[int(firstIndex)]
          except IndexError:
              self.value = None
          self.modalPane.destroy()
  
      def _cancel(self, event=None):
          self.modalPane.destroy()
  
      def returnValue(self):
          self.master.wait_window(self.modalPane)
          return self.value
  
  if __name__ == '__main__':
      import random
      root = Tk()
  
      returnValue = True
      list = [random.randint(1,100) for x in range(50)]
      while returnValue:
          returnValue = ListBoxChoice(root, "Number Picking",\
                       "Pick one of these crazy random numbers",\
                       list).returnValue()
          print returnValue
  </code></pre>
  
  <p>Now this example says to do something like this:<br />
  <code>results = ListBoxChoice(root, list=listOfItems).returnValue()</code>.</p>
  
  <p>What I'm trying to do is provide a list of values from which the user selects a single value.  The window should close before I use the results from the selected value. Here is that code:</p>
  
  <pre><code>from tkinter import Tk, Label
  form ListBoxChoice import ListBoxChoice
  ...
  eventList = ["20190120","20190127","20190203"]
  root = Tk()
  root.withdraw() # This causes the ListBoxChoice object not to appear
  selectValue = ListBoxChoice(root, title="Event",\
                message="Pick Event", list=eventList).returnValue()
  root.wait_window() # Modal Pane/window closes but not the root
  print("selectValue:", selectValue)
  </code></pre>
  
  <p>A <code>root</code> window is placed behind the <code>modalPane</code> (<code>Toplevel</code>).  I have to close that window before the calling process continues.  So there is a block in place.</p>
  
  <p>I've tried to put a <code>sleep(1.01)</code> command above but had no impact.
  How do I get the <code>ListBoxChoice</code> to close once the selection has been made
  before my <code>print</code> statement of the <code>selectValue</code>?  For it is at that point I want to use the results to plot data.</p>
  
  <p>If I don't use <code>root.wait_winow()</code>, it is only when the plot is closed (end of the process) that the <code>ListBoxChoice</code> box close as well.</p>
  
  <p>Suggestions?</p>