title: Time interval in tkinter before switching frames
body: <p>I need help for my code. I want to change the background of my button before switching the page or frame. In my code, the frame switches but I don't see the button changing it's background color and if I remove the code to switch the frame which is this <code>frame1.after(2000, show_frame(frame2))</code> which has a delay and it works.</p>
  <p>Any idea how to fix this? Thanks</p>
  <pre><code>from tkinter import *
  
  root = Tk()
  root.geometry(&quot;500x500&quot;)
  
  root.rowconfigure (0, weight = 1)
  root.columnconfigure (0, weight = 1)
  
  frame1 = Frame (root, bg = &quot;yellow&quot;)
  frame2 = Frame (root, bg = &quot;blue&quot;)
  
  
  def show_frame(frame):
      frame.tkraise()
  
  for frame in (frame1,frame2):
      frame.grid(row = 0, column = 0, sticky = 'nsew')
  
  #the problem is here
  def to_frame2():
      b.config(bg = &quot;black&quot;)
      frame1.after(2000, show_frame(frame2))
  
  b = Button(frame1, text = &quot;Frame 2&quot;, command = to_frame2)
  b.pack()
  
  show_frame(frame1)
  root.mainloop()
  </code></pre>