title: I want to change the background color of the button when I click in tkinter GUI
body: <p>I have a python GUI code to open and close. I need to modify the code like when I press the open button the button colour turns into green and when I press close button the open button colour changes to its default colour.</p>
  
  <pre><code>from serial import*
  from time import*
  from tkinter import*
  
  window = Tk()
  
  def open_command():
      print("Opening")
  
  def close_command():
      print("Closing")
  
  b = Button(window, text = "Open", font = ("Times New Roman", 12), fg = "green", bg = "white", height = 1, width = 5, command = open_command).pack()
  b = Button(window, text = "Close", font = ("Times New Roman", 12), fg = "red", bg = "white", height = 1, width = 5, command = close_command).pack()
  
  mainloop()
  </code></pre>
  
  <p>when clicking open button colour of open button needs to change from its default colour to green. If we click close button close button colour needs to change red and open button colour changes to its default colour.</p>