title: Python: Tie an action to a Checkbutton
body: <p>From what I've been able to find in internet tutorials, the Checkbutton has a <em><code>command</code></em> option.  So, either this is incorrect, or I am stumped as to how to use the option.  What I'm trying to do is to have a text Entry box be gray (<code>disabled</code>) when the Checkbutton is not checked, and to enable the text Entry box when the Checkbutton is checked.</p>
  
  <p>My code:
      class OutputSettings:
        def <strong>init</strong>(self, master):</p>
  
  <pre><code>    frame = LabelFrame(master, text = 'Debug')
      frame.grid(row=2, column=0, columnspan = 2)
  
      self.make_txt = BooleanVar()
      self.make_txt.set(True)
  
      self.create_a_file = Checkbutton(frame, text = 'Create Text File')
      self.create_a_file.config(variable = self.make_txt, 
                                command = self.graytextbox())
      self.create_a_file.pack()
  
  
      Label(frame, 
            text="Text File \nSave Location:", 
            font = "Verdana 8").pack()
  
      self.file_location = StringVar()
      self.file_location =   Entry (frame, width=30, textvariable = self.file_location)
      self.file_location.pack()
      self.file_location.insert(0, 'C:\Temp\ETHresults.txt')
  
  
    def graytextbox(self):
  
      if self.make_txt == True:
          self.file_location.config(state=DISABLED)
          # I've also tried self.file_location.state(['DISABLED'])
      else:
          self.file_location.config(state=NORMAL)
          # I've also tried self.file_location.state(['NORMAL'])
  </code></pre>
  
  <p>Not only does the code not control the normal/disabled function of the button, but I get <code>AttributeError: instance has no attribute 'file_location'</code></p>