title: How to read text from a Tkinter Text Widget
body: <pre><code>from Tkinter import *
  window = Tk()
  
  frame=Frame(window)
  frame.pack()
  
  text_area = Text(frame)
  text_area.pack()
  text1 = text_area.get('0.0',END)
  
  def cipher(data):
      As,Ts,Cs,Gs, = 0,0,0,0
      for x in data:
          if 'A' == x:
              As+=1 
          elif x == 'T':
              Ts+=1
          elif x =='C':
              Cs+=1
          elif x == 'G':
              Gs+=1
  
      result = StringVar()
      result.set('Num As: '+str(As)+' Num of Ts: '+str(Ts)+' Num Cs: '+str(Cs)+' Num Gs: '+str(Gs))
      label=Label(window,textvariable=result)
      label.pack()
  
  button=Button(window,text="Count", command= cipher(text1))
  button.pack()
  window.mainloop()
  </code></pre>
  
  <p>What I'm trying to accomplish is entering a string of 'AAAATTTCA' in my Text widget and have the label return the number of occurrences. With the entry 'ATC' the function would return Num As: 1 Num Ts: 1 Num Cs: 1 Num Gs: 0.</p>
  
  <p>What I don't understand is why I am not reading in my text_area correctly. </p>