title: Repeatedly iterating through a list, with buttons and bindings
body: <p>So I'm making a maths test in TkInter (Python 3.4.3). I want to use only one frame for all questions. I have a list that contains all of the strings (<code>QStringList</code>, imported from another .py), which are used as the text variables for a label.</p>
  
  <p>When the user presses <kbd>Return</kbd>, or the Button, I want to iterate to the next item in the list, so there's a new question displayed.
  With my current code, I can only successfully do this once. Presumably because the 'CurrentQ' variable gets set back to 0 each time.
  How do do this so that each time I call the function, the next list item is displayed?</p>
  
  <p>This code is in my <code>TestPage(tk.Frame):</code> class.</p>
  
  <pre><code>def __init__(self,parent,controller):
      tk.Frame.__init__(self,parent)
  
      CurrentQ = 0
  
      #QUESTION LABEL
      self.CurrentQStringVar = tk.StringVar()
      self.CurrentQString = tk.Label(self, textvariable=self.CurrentQStringVar,
                                 anchor='w',fg="black", bg="yellow", font=STANDARD_FONT)
      self.CurrentQString.grid(column=0,row=0,columnspan=2, sticky='EW')
      self.CurrentQStringVar.set(QStringList[CurrentQ])
  
      #ANSWER ENTRY BOX
      self.UserAnsEntryVar = tk.StringVar()
      self.UserAnsEntry = tk.Entry(self,textvariable=self.UserAnsEntryVar)
      self.UserAnsEntry.grid(column=0,row=1,sticky='EW')
      self.UserAnsEntry.bind("&lt;Return&gt;",
                             lambda event, CurrentQ=CurrentQ:
                             self.TestEnterKey(self,CurrentQ))
      self.UserAnsEntryVar.set("")
  
      #ANSWER BUTTON
      self.UserAnsButtonVar = tk.StringVar()
      self.UserAnsButton = ttk.Button(self,text="ENTER",
                                      command= lambda: self.TestEnterKey(self,CurrentQ))
      self.UserAnsButton.grid(column=0,row=2,columnspan=2, stick='EW')
  
  def TestEnterKey(self,event,CurrentQ):
      CurrentQ += 1
      self.CurrentQStringVar.set(QStringList[CurrentQ])
      return CurrentQ
  </code></pre>
  
  <p>I tried to use the <code>CurrentQ</code> as an argument in the function, but maybe I have to use a <code>lambda</code>.</p>
  
  <p>edit: my actual QStringList is really long, and contains other (randomly generated) variables. So for this I guess it'd be better to just have...</p>
  
  <pre><code>QStringList = ["Q1","Q2","Q3","Q4","Q5","Q6","Q7","Q8","Q9","Q10"]
  </code></pre>