title: Global string from a text widget?
body: <p>I am a newbie struggling to get <strong>two</strong> simple string inputs out of a text widget and use it later in my program.  How do I migrate the strings <code>keypad</code> and <code>message</code> to input them elsewhere?</p>
  
  <pre><code>#Text widget to input 2 text strings and store as 'keypad' and 'message'
  from tkinter import *
  master = Tk()
  master.title("simple one time pad")
  master.resizable(0,0)
  
  global keypad
  global message
  
  k = Text(master, width=50,height=10)
  k.pack()
  
  separator = Frame(height=2, bd=1, relief=SUNKEN)
  separator.pack(fill=X, padx=5, pady=5)
  
  m = Text(master, width=50,height=10)
  m.pack()
  
  def encrypt():         
      keypad = (k.get(1.0, END))
      str(keypad)
      message = (m.get(1.0, END))
      str(message)
  
      print(keypad)
      print(message)            
  
  mb = Button(master, text="Encrypt", command=encrypt)
  mb.pack(anchor=N)
  
  mainloop()
  
  print(keypad)
  print(message)
  </code></pre>
  
  <p>Gives the following error: </p>
  
  <pre class="lang-none prettyprint-override"><code>Traceback (most recent call last):
    File "/home/maverick/Window-hell-1.py", line 39, in &lt;module&gt;
      print(keypad)
  NameError: name 'keypad' is not defined
  </code></pre>
  
  <p>I get the first set of <code>print()</code> In the <code>def encrypt:</code> but crashes after the <code>mainloop()</code>.
  I tried the whole <code>self.xxx</code> routine but then my widget wouldn't function.</p>