title: How do I stop a timer in Python (tkinter)?
body: <p>My aim is to create a simple timer program. It updates itself constantly until the <strong>stopButton</strong> is pressed. However, I am unsure how to stop the tick function from running so that the timer stays the same once the <strong>stopButton</strong> is pressed.</p>
  
  <p>This is my code so far:</p>
  
  <pre><code>import tkinter
  
  root = tkinter.Tk()
  root.title('Timer')
  root.state('zoomed')
  
  sec = 0
  
  def tick():
      global sec
  
      sec += 0.1
      sec = round(sec,1)
      timeLabel.configure(text=sec)
      root.after(100, tick)
  
  def stop(): 
      # stop the timer from updating.
  
  timeLabel = tkinter.Label(root, fg='green',font=('Helvetica',150))
  timeLabel.pack()
  
  startButton = tkinter.Button(root, text='Start', command=tick)
  startButton.pack()
  
  stopButton = tkinter.Button(root, text='Stop', command=stop)
  stopButton.pack()
  
  root.mainloop()
  </code></pre>
  
  <p>What would be a possible way of stopping the <code>tick()</code> function?</p>
  
  <p>Any help would be greatly appreciated!</p>