title: Tkinter: Updating progressbar when a function is called
body: <p>Imagine the following simple example:</p>
  
  <pre><code>def doNothing():
    sleep(0.5)
    barVar.set(10)
    sleep(0.5)
    barVar.set(20)
    sleep(0.5)
    barVar.set(30)
  
  mainWindow = Tk()
  barVar = DoubleVar()
  barVar.set(0)
  bar = Progressbar(mainWindow, length=200, style='black.Horizontal.TProgressbar', variable=barVar, mode='determinate')
  bar.grid(row=1, column=0)
  button= Button(mainWindow, text='Click', command=doNothing)
  button.grid(row=0, column=0)
  mainWindow.mainloop()
  </code></pre>
  
  <p><strong>What I get</strong> when I run this, the progressbar is already at 30% when clicking the button, no progress in front of me. Like attached:</p>
  
  <p><a href="https://i.stack.imgur.com/haNW1.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/haNW1.jpg" alt="enter image description here"></a></p>
  
  <p><strong>What I need:</strong>  <strong><em>I can see the progress in front of me</em></strong> (not hanging then suddenly 30%)</p>
  
  <p><strong>Update:</strong>
  I upadted the code according to @Bernhard answer, but still I <strong><em>can not see the progress in front of me</em></strong>. Just a sudden jump of 30% after waiting 1.5 sec</p>
  
  <p><strong>Seocnd Update:</strong>
  I'm only using sleep here as a simulation for a process that takes time, like connecting over ssh and grabing some info.</p>