title: How to return a value of a function given as a command in tkinter
body: <p>I've written a very simple code with python <code>tkinter</code>, it contains an input box. I'd like to keep the value inserted by the user to myself, in case I need to use it later.</p>
  <p>Here's the code:</p>
  <pre><code>import tkinter as tk 
     
  root=tk.Tk() 
    
  root.geometry(&quot;600x400&quot;) 
     
  def submit(): 
    
      name=name_entry.get() 
      return name
         
  name_label = tk.Label(root, text = 'Username', 
                        font=('calibre', 
                              10, 'bold')) 
      
  name_entry = tk.Entry(root, 
                        font=('calibre',10,'normal')) 
       
  sub_btn=tk.Button(root,text = 'Submit', 
                    command = submit) 
  
  name_label.grid(row=0,column=0) 
  name_entry.grid(row=0,column=1)  
  sub_btn.grid(row=2,column=1) 
  
  root.mainloop() 
  </code></pre>
  <p>In function <code>submit</code> I've written <code>return name</code>, in order to return the inserted name of the user. But how can I access it outside of the function? I want to keep the value somewhere, but I don't know how to.</p>
  <p>I appreciate your kind help in advance</p>