title: How to properly make Tkinter buttons in a for loop?
body: <p>So I want to print an item's text when item's button is pressed.</p>
  
  <pre><code>from tkinter import *
  from tkinter import ttk
  
  root = Tk()
  root.title('test')
  
  mainframe = ttk.Frame(root, padding='8')
  mainframe.grid(column=0, row=0)
  
  items = [
      {
          'name' : '0001',
          'text' : '1111',
      },{
          'name' : '0002',
          'text' : '2222',
      },{
          'name' : '0003',
          'text' : '3333',
      },
  ]
  
  rcount = 1 #row count
  for item in items:
      ttk.Label(mainframe, text=item['name']).grid(column=1, row=rcount, sticky=W)
      ttk.Button(mainframe, text='-&gt;', command=lambda:print(item['text'])).grid(column=2, row=rcount, sticky=W)
      rcount += 1
  
  root.mainloop()
  </code></pre>
  
  <p>Whichever of the three buttons I press I get <code>3333</code>. If I remove lambda I get <code>1111 2222 3333</code> right at start of the program, but then buttons have no effect.</p>