title: How can I control and obtain real-time return value for python script, using tkinter?
body: <p>I am doing a GUI for my python script, right now I'm using the Tkinter.</p>
  <p>I write the main function a continuous <code>While</code> loop, so that it can keep tracking the data changes.
  For the GUI, I created a start and end button to start running or stop the script. My problem is that, I linked the main function to the GUI module. But when I clicked the start button the GUI module just went no-responding and the main function kept running. My code looks like this,</p>
  <pre><code>
  class Application(Frame):
      def __init__(self, master=None):
          Frame.__init__(self, master)
          self.pack()
          self.createWidgets()
  
      def createWidgets(self):
          self.startButton = Button(self, text='Start', command=main)
          self.startButton.pack()
          self.quit = Button(self, text=&quot;QUIT&quot;, fg=&quot;red&quot;, command=self.master.destroy)
          self.quit.pack(side=&quot;bottom&quot;)
  
  
  def main():
      While True:
         # keep running to monitor the data changing
         print(changed value) 
  
  
  
  app = Application()
  app.master.title('Auto Detection')
  app.mainloop()
  
  
  </code></pre>
  <p>How can I control the running of the main function via GUI module, do I need to change the main function?
  And can I obtain the real-time return value of the main function on the GUI?
  Thanks so much.</p>