title: closing tkinter menu after selection is made
body: <p>I Found this script on <a href="https://pythonspot.com/tk-dropdown-example/" rel="nofollow noreferrer">pythonspot</a> tutorial, But I can't make it close after a selection has been made, I tried adding<code>root.destroy()</code> but it didn't do it. What I want is basically to store the selection in a variable (so I can use later on) and destroy the window after selection.
  I am very new to <code>tkinter</code></p>
  
  <pre><code>from tkinter import *
  root = Tk()
  root.title("Tk dropdown example")
  
  # Add a grid
  mainframe = Frame(root)
  mainframe.grid(column=0,row=0, sticky=(N,W,E,S) )
  mainframe.columnconfigure(0, weight = 1)
  mainframe.rowconfigure(0, weight = 1)
  mainframe.pack(pady = 100, padx = 100)
  
  # Create a Tkinter variable
  tkvar = StringVar(root)
  
  # Dictionary with options
  choices = { 'Pizza','Lasagne','Fries','Fish','Potatoe'}
  tkvar.set('Pizza') # set the default option
  
  popupMenu = OptionMenu(mainframe, tkvar, *choices)
  Label(mainframe, text="Choose a dish").grid(row = 1, column = 1)
  popupMenu.grid(row = 2, column =1)
  
  # on change dropdown value
  def change_dropdown(*args):
      print( tkvar.get() )
  
  # link function to change dropdown
  tkvar.trace('w', change_dropdown)
  
  root.mainloop()
  #root.destroy()
  </code></pre>