title: Dynamically Deleting Widgets Stored in a List is causing index error
body: <p>After reading some different posts here, I still cannot resolve this issue.  I'm trying to dynamically add and remove widgets from a frame using buttons.</p>
  <p>The add button will add an entry/button/label.  The button that is added to that row should delete said row.  I am not getting the expected behavior.</p>
  <p>What is happening is that it doesn't seem like the button command is updated properly and/or maybe I have made some other mistake in the logic.
  A short reproducible example is here.  Press the add button three times, then delete the top row 3 times.  The last one will cause an index error.</p>
  <p>There are many ways to reproduce said error (add more than 2, add several, then delete them and you can watch the index update properly in most cases.  I cannot understand the times when it doesn't, but if you add up to 4 or more and delete the top item, you can see that the index called when I hit delete on the row the second time is actually 4!?</p>
  <p>I am pretty sure this should get fixed on the original loop when I update the command for the button?</p>
  <pre><code>import tkinter as tk
  from tkinter import ttk
  import time
  
  class App(tk.Tk):
      def __init__(self,*args,**kwargs):
          tk.Tk.__init__(self,*args,**kwargs)
          
          self.addButton = ttk.Button(self,command=self.add,text='Add')
          self.addButton.pack()
          
          self.frame = tk.Frame(self)
          self.frame.pack()
          
          self.inputs  = []
          self.buttons = []
          self.labels  = []
          
      def add(self):
          self.addButton['state'] = 'disabled'
          c = len(self.inputs)
          
          self.inputs.append(ttk.Entry(self.frame))
          self.buttons.append(ttk.Button(self.frame,text='x',command=lambda: self.remove(c)))
          self.labels.append(ttk.Label(self.frame,text=str(c)))
          
          self.inputs[c].grid(row=c,column=0)
          self.buttons[c].grid(row=c,column=1)
          self.labels[c].grid(row=c,column=2)
          
          self.addButton['state'] = 'enabled'
          return
      
      def remove(self,i):
          self.buttons[i]['state'] = 'disabled'
          print(i,self.labels[i]['text'])
          
          ## Move all buttons and lower up one
          for x in range(i+1,len(self.buttons)):
              self.buttons[x].configure(command=lambda: self.remove(x-1))
              self.buttons[x].grid(row=x-1,column=1)
              self.inputs[x].grid(row=x-1,column=0)
              self.labels[x].grid(row=x-1,column=2)
              self.labels[x].configure(text=str(x-1))
      
          ## Delete widgets
          self.buttons[i].destroy()
          self.inputs[i].destroy()
          self.labels[i].destroy()
          
          ## Remove from list
          del self.buttons[i]
          del self.inputs[i]
          del self.labels[i]
          
          return
          
  if __name__ == '__main__':
      
      app = App()
      app.mainloop()
  </code></pre>
  <p>EDIT:
  Solution in comments.<br />
  Changed
  <code>self.buttons[x].configure(command=lambda: self.remove(x-1))</code>
  to
  <code>self.buttons[x].configure(command=lambda x=x: self.remove(x-1))</code></p>