title: How do I run a while loop in tkinter window while it is open?
body: <p>I have a <code>while</code> loop that I want to run while the Tkinter window is open but the Tkinter window doesn't even open when the <code>while</code> loop is running.</p>
  
  <p>This is a problem since my <code>while</code> loop is an infinite loop.</p>
  
  <p>I basically want to create a programme that provides the users with new choices after a previous choice is selected by updating the buttons through a <code>while</code> loop, but whenever I use a <code>while</code> loop Tkinter doesn't open the window until I end the loop.</p>
  
  <pre><code>root = Tk()
  i=0
  while i==0:
      def choice1():
          list1[a1].implement()
          list1.remove(list1[a1])
      def choice2():
          list2[a2].implement()
          list2.remove(list2[a2])
  
  button1 = tk.Button(root, text=list1.headline, command=choice1)
  button2 = tk.Button(root, text=list2.headline, command =choice2)
  root.mainloop()
  </code></pre>
  
  <p>Also, an error shows up because tkinter keeps executing this loop until there are no items in list1 or list2 left.</p>
  
  <p><strong>What I want to know is if there is a way to run Tkinter window while the while loop is going on</strong></p>
  
  <p>(<code>a1</code> and <code>a2</code> are randomly generated numbers.)</p>