title: Python Tkinter, Stop a threading function
body: <p>I'm currently developing a GUI for a 3D printer and I'm having a problem of how to stop a threading function. I want to be able to click a button that has another function within my GUI that will stop the threading function from sending strings of G-code across the serial port. Currently the function has threading incorporated to allow other functions to be triggered during printing. I would greatly appreciate some advice on how I would incorporate this stop feature. </p>
  
  <p>Below is the function that opens a G-code file and sends each line across the serial port.</p>
  
  <pre><code>def printFile():
  def callback():
      f = open(entryBox2.get(), 'r');
      for line in f:
          l = line.strip('\r')
          ser.write("&lt;" + l + "&gt;")
          while True:
              response = ser.read()
              if (response == 'a'):
                  break
  t = threading.Thread(target=callback)
  t.start()
  </code></pre>