title: Python, Tkinter: how can I prevent tkinter gui mainloop crash using threading
body: <p>Hi I have a small python gui interface with two buttons, start(That starts a counter) and stop (that is suppose to stop the counter), the counter is an infinite loop since I do not want it to end unless the second button is clicked. The problem is the second button cannot be clicked while the function from the first one is still running.
  I read that I need to use threading and I have tried but I do not fully understand how I can do this. Please help.</p>
  
  <pre><code>from Tkinter import *
  import threading
  
  
  class Threader(threading.Thread):
      def run(self):
          for _ in range(10):
              print threading.current_thread().getName()
  
      def main(self):
          import itertools
          for i in itertools.count(1, 1):
              print i
  
      def other(self):
          print "Other"
  
  m = Threader(name="main")
  o = Threader(name="other")
  
  try:
      '''From here on we are building the Gui'''
      root = Tk()
  
      '''Lets build the GUI'''
      '''We need two frames to help sort shit, a left and a right vertical frame'''
      leftFrame = Frame(root)
      leftFrame.pack(side=LEFT)
      rightFrame = Frame(root)
      rightFrame.pack(side=RIGHT)
      '''Widgets'''
      '''Buttons'''
      playButton = Button(leftFrame, text="Play", fg="blue", command=m.main)
      stopButton = Button(rightFrame, text="Stop", fg="red", command=o.other)
      playButton.pack(side=TOP)
      stopButton.pack(side=BOTTOM)
  
      root.mainloop()
  except Exception, e:
      print e
  </code></pre>