title: how to create traceable widgets with functions (python, tkinter)
body: <p>I'm currently trying to create the GUI with tkinter for a very specific data processing tool. The user will load a file via a button and depending on that data the tool will display a number of dropdown-menues to choose options specific to the provided data. 
  Right now I am stuck on creating those widgets after initializing the mainloop (I need to initialize/ update them after the fact, because the user should also be able to load several files). The widgets are being displayed, though I cannot access their value, because that is a local variable inside the function.</p>
  
  <p>TLDR: I want to create and update tkinter widgets after initializing the window and its values need to be accessible</p>
  
  <p>I tried writing a function as seen below, which would trigger depending on other code. Sadly, the values they provide do only reflect the value of the widget (in this case the dropdown) at the termination of the function and do not change with the widget.
  Changing them to global variables didn't fix the updating-problem either.
  I looked into different ways to create widgets after the fact, but do not seem to find a way.</p>
  
  <pre><code>import tkinter as tki
  
  root = tki.Tk()
  root.title('Data Comparison')
  
  #specifying a frame and its grid
  frame = tki.Frame(root)
  frame.grid(column=9, row=7)
  
  #I'm working with dicts, not lists, because that more accurately represents my
  #actual data
  numbers= {'one':1, 'two':2, 'three':3, 'four':4} 
  colors= {'blue':5, 'red':6, 'green':7, 'orange':8, 'pink':9, 'yellow':10}
  
  def createDropdown():
      global DDvalue
      DDvalue = tki.StringVar(root)
      DDvalue.set(list(numbers)[0]) 
      global DDvalues
      DDvalues = tki.OptionMenu(frame, DDvalue, *numbers)
      DDvalues.grid(column= 7, row = 1)
  #the global variables only display the accurate value at the time of creation of the widget
  createDropdown()
  
  def displayvalue():
      print(str(DDvalue.get()))
  
  DDvalue.trace_add('write', displayvalue())
  
  def updateDropdown():
      DDvalues.destroy
  
  btnupdate= tki.Button(frame, text='update', command= updateDropdown)
  btnupdate.grid (column= 8, row= 7)
  
  #I also could not delete the widget with the button above
  
  root.mainloop()
  </code></pre>
  
  <p>Right now the trace_add only prints the value once, at the creation of the widget (one), afterwards, changing the value results in this error message: 
  TypeError: 'NoneType' object is not callable</p>
  
  <p>Also, the update button is not capable of accessing the widget</p>
  
  <p>I would like to see the values of a widget created after meeting certain conditions to be accessible.</p>