title: Label error in tkinter while exiting window
body: <p>I am trying to make a digital clock through python tkinter .My code is</p>
  <pre><code>import tkinter,time
  
  def exiter():
      root.destroy()
  
  root=tkinter.Tk()
  root.title(&quot;Digital Clock&quot;)
  root.geometry(&quot;340x100&quot;)
  root.resizable(False,False)
  root.protocol(&quot;WM_DELETE_WINDOW&quot;,exiter)
  
  def time_setter():
      hr=tkinter.Label(root,font=('k',60,'bold'),text=time.strftime(&quot;%H:%M:%S&quot;))
      hr.grid(row=0,column=0)
  
      
  
  while True:
      root.update()
      time_setter()
  </code></pre>
  <p>After I close the window I get an error</p>
  <pre><code>Traceback (most recent call last):
    File &quot;c:\Users\Tanmay Daga\OneDrive\Documents\Programming\Clock-Tkinter\digital_clock.py&quot;, line 20, in &lt;module&gt;
      time_setter()
    File &quot;c:\Users\Tanmay Daga\OneDrive\Documents\Programming\Clock-Tkinter\digital_clock.py&quot;, line 13, in time_setter
      hr=tkinter.Label(root,font=('k',60,'bold'),text=time.strftime(&quot;%H:%M:%S&quot;))
    File &quot;C:\Program Files\Python39-32\lib\tkinter\__init__.py&quot;, line 3145, in __init__
      Widget.__init__(self, master, 'label', cnf, kw)
    File &quot;C:\Program Files\Python39-32\lib\tkinter\__init__.py&quot;, line 2569, in __init__
      self.tk.call(
  _tkinter.TclError: can't invoke &quot;label&quot; command: application has been destroyed
  </code></pre>
  <p>How do I break the loop when the window is closed.<br>
  How do I know when the window is closed</p>