title: How to change the color of a Tkinter label programmatically?
body: <p>I am trying to change the color of a Tkinter label when ever the user clicks the check button. I am having trouble writing the function correctly and connecting that to the command parameter.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>import Tkinter as tk
  
  root = tk.Tk()
  app = tk.Frame(root)
  app.pack()
  
  label = tk.Label(app, bg="white", pady=5, font=(None, 1), height=20, width=720)
  checkbox = tk.Checkbutton(app, bg="white", command=DarkenLabel)
  label.grid(row=0, column=0, sticky="ew")
  checkbox.grid(row=0, column=0, sticky="w")
  
  def DarkenLabel():
      label.config(bg="gray")
  
  root.mainloop()
  </code></pre>
  
  <p>Thank you</p>