title: Disabling buttons after click in Tkinter
body: <p>I'm new to Python and I'm trying to make a simple application using Tkinter.</p>
  
  <pre><code>def appear(x):
      return lambda: results.insert(END, x)
  
  letters=["A", "T", "D", "M", "E", "A", "S", "R", "M"] 
  
  for index in range(9): 
      n=letters[index] 
      nButton = Button(buttons, bg="White", text=n, width=5, height=1,
      command =appear(n), relief=GROOVE).grid(padx=2, pady=2, row=index%3,
      column=index/3)
  </code></pre>
  
  <p>What I'm trying to do is disable the buttons once I click them.
  I tried</p>
  
  <pre><code>def appear(x):
      nButton.config(state="disabled")
      return lambda: results.insert(END, x)
  </code></pre>
  
  <p>But it gives me the following error:</p>
  
  <blockquote>
    <p>NameError: global name 'nButton' is not defined</p>
  </blockquote>