title: Class Variable Retrieval in Python
body: <p>This is a GUI I’ve been writing for a script I already have working. What I’m struggling with here is retrieving the information in the textboxes.    </p>
  
  <p>Under the definition <code>generate</code> I am able to pop a name off of <code>listx</code> but I am unable to grab the local variable <code>entry</code> from any of the instances of the <code>new_title_box</code> class.</p>
  
  <pre><code>from Tkinter import *
  import ttk
  boxvar=""
  folder=""
  listx=[]
  count = 1
  myrow = 1
  
  class new_title_box:
      def __init__(self,name):
          global myrow, count, listx
          self.entry = StringVar()
          self.name = name
          self.name = ttk.Entry(mainframe,width=45,textvariable=self.entry)
          self.name.grid(column=1,row=myrow+1,sticky=(N,W))
          listx.append(name)
          print(listx) ## For debugging to insure that it is working correctly, if it gives output it, this part works
          myrow = myrow + 1
          count=count+1
  
  def make_new(*args):
      new_title_box('box'+str(count))
  
  def generate(*args):
      global listx, boxvar
      while len(listx) &gt; 0:
          boxvar=listx.pop(0)
          print(boxvar) ## For debugging to insure that it is working correctly, if it gives output it, this part works
          folder = boxvar.entry.get() ## Not working here
          print(folder) ## For debugging to insure that it is working correctly, if it gives output it, this part works
  
  root = Tk()
  root.title("File Maker")
  
  mainframe = ttk.Frame(root, padding = "50 50 50 50")
  mainframe.grid(column = 0,row = 0,sticky = (N, W, E, S))
  mainframe.columnconfigure(0,weight=1)
  mainframe.columnconfigure(0,weight=1)
  
  add_entry = ttk.Button(mainframe,width=20, text = "add entry", command=make_new)
  add_entry.grid(column=2,row=2,sticky=(N,W))
  add_entry = ttk.Button(mainframe,width=20, text = "make files", command=generate)
  add_entry.grid(column=2,row=3,sticky=(N,W))
  
  root.mainloop()
  </code></pre>
  
  <p>Here's the traceback I'm getting:</p>
  
  <pre><code>Exception in Tkinter callback 
  Traceback (most recent call last): 
    File "C:\Python33\lib\tkinter_init_.py", line 1442, in call 
      return self.func(*args) 
    File "C:\python\SampAqTkinter.py", line 28, in generate 
      folder = boxvar.entry ## Not working here 
  AttributeError: 'str' object has no attribute 'entry'
  </code></pre>