title: Indeterminate Progress bar while function is running
body: <p>I have a GUI which has two buttons and a progressbar stacked on a single column. Each button calls a different function which takes some time to execute. I want the progress bar to move when someone clicks any of the two buttons and keep moving (indeterminately) until the function finishes and then stop. I know I need to use multi-threading but I can't seem to get the code right!</p>
  
  <p>Code</p>
  
  <pre><code>from tkinter import Tk
  import time 
  from tkinter import *
  from tkinter import Button
  from tkinter import Frame
  from tkinter import ttk
  import threading
  
  
  def sample_function():
      time.sleep(2)  # SAMPLE FUNCTION BEING CALLED
  
  def prepare_clicked():
      sample_function()  
  
  def social_clicked():
  
      sample_function()
  
  def anomaly_clicked():
      sample_function()             
  
  
  
  window = Toplevel() # Tried using Tk but I am using image to design each buttons through the button config in my actual code and tk throws error
  topFrame = Frame(window)
  topFrame.pack()
  
  prepare_btn = Button(topFrame, command=prepare_clicked,text='Button1')
  anomaly_btn = Button(topFrame,command=anomaly_clicked,text='Button2')
  social_btn = Button(topFrame, command=social_clicked,text='Button3')
  processing_bar = ttk.Progressbar(topFrame, orient='horizontal', mode='indeterminate')
  
  
  
  window.rowconfigure((0,1), weight=1)  # make buttons stretch when
  window.columnconfigure((0,3), weight=1)  # when window is resized
  prepare_btn.grid(row=0, column=1, columnspan=1, sticky='EWNS')
  anomaly_btn.grid(row=1, column=1, columnspan=1, sticky='EWNS')
  social_btn.grid(row=2, column=1, columnspan=1, sticky='EWNS')
  processing_bar.grid(row=3, column=1, columnspan=1, sticky='EWNS')
  
  
  window.mainloop()
  </code></pre>