title: How to ensure FuncAnimation runs smoothly in tkinter when doing processing / other work?
body: <p>I am trying to create a live plot using tkinter and matplotlib. The thing is, animate might be doing some "heavy" work, just heavy enough to freeze the tkinter window for a little bit every time the animate is being called. For the sake of simplicity, I have created a simple plot, inside of a tkinter window.</p>
  
  <pre><code># --- Imports
  from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
  import tkinter as Tk
  import numpy as np
  import matplotlib.pyplot as plt
  import matplotlib.animation as animation
  # --- End of imports
  
  fig = plt.Figure()
  
  x = np.arange(0, 2*np.pi, 0.01)
  
  
  def animate(i):
      for j in range(10000000):
          k=j
      line.set_ydata(np.sin(x + i / 10.0))
      return line
  
  root = Tk.Tk()
  
  label = Tk.Label(root, text="Graph")
  label.grid(column=0, row=0)
  
  canvas = FigureCanvasTkAgg(fig, master=root)
  canvas.get_tk_widget().grid(column=0, row=1)
  
  ax = fig.add_subplot(111)
  line, = ax.plot(x, np.sin(x))
  
  ani = animation.FuncAnimation(fig, animate, np.arange(1, 200), interval=250, blit=False)
  
  Tk.mainloop()
  </code></pre>
  
  <p>If you run the code and try to move the window around, you will notice a slight freezing every time animation gets called. Note that this is not the actual code for my project, just an over simplification. I have put the for-loop to simulate the heavy work the animate function might be doing.</p>
  
  <p>So, is there a way for the animate to run separately from the tkinter mainloop? I've tried to create a different thread for the animate but i could not get it to work. Any help would be appreciated. Thanks!</p>