title: Why does my button only work once in Tkinter?
body: <p>I'm trying to create a window that's background changes color when you press a button. But the button only changes the color once, then doesn't do anything.</p>
  <pre><code>from tkinter import *
  import random
  
  colors = [&quot;blue&quot;, &quot;red&quot;, &quot;green&quot;]
  
  colorChoice = random.choice(colors)
  
  window = Tk()
  
  window.geometry(&quot;400x400&quot;)
  
  def changeColor():
      window.configure(background=str(colorChoice))
  
  button = Button(window, text = &quot;click me!&quot;, command=changeColor)
  button.pack(side = TOP)
  
  
  window.mainloop()
  </code></pre>