title: Tkinter: ProgressBar with indeterminate duration
body: <p>I would like to implement a progress bar in Tkinter which fulfills the following requirements:</p>
  
  <ul>
  <li>The progress bar is the only element within the main window </li>
  <li>It can be started by a start command without the need of pressing any button</li>
  <li>It is able to wait until a task with unknown duration is finished</li>
  <li>The indicator of the progress bar keeps moving as long as the task is not finished</li>
  <li>It can be closed by a stop command without the need of pressing any stop bar</li>
  </ul>
  
  <p>So far, I have the following code:</p>
  
  <pre><code>import Tkinter
  import ttk
  import time
  
  def task(root):
      root.mainloop()
  
  root = Tkinter.Tk()
  ft = ttk.Frame()
  ft.pack(expand=True, fill=Tkinter.BOTH, side=Tkinter.TOP)
  pb_hD = ttk.Progressbar(ft, orient='horizontal', mode='indeterminate')
  pb_hD.pack(expand=True, fill=Tkinter.BOTH, side=Tkinter.TOP)
  pb_hD.start(50)
  root.after(0,task(root))
  time.sleep(5) # to be replaced by process of unknown duration
  root.destroy()
  </code></pre>
  
  <p>Here, the problem is that the progress bar does not stop after the 5s are over.</p>
  
  <p>Could anybody help me finding the mistake?</p>