title: Create a tkinter window every x minutes and then automatically close it after y seconds
body: <p>I'm trying to build a simple program to remind me to take breaks while using the computer. I have a reasonable understanding of python but have never played with GUI programming or threading before, so the following is essentially copying/pasting from stackoverflow:</p>
  
  <pre><code>import threading
  import time
  import Tkinter
  
  class RepeatEvery(threading.Thread):
      def __init__(self, interval, func, *args, **kwargs):
          threading.Thread.__init__(self)
          self.interval = interval  # seconds between calls
          self.func = func          # function to call
          self.args = args          # optional positional argument(s) for call
          self.kwargs = kwargs      # optional keyword argument(s) for call
          self.runable = True
  
      def run(self):
          while self.runable:
              self.func(*self.args, **self.kwargs)
              time.sleep(self.interval)
  
      def stop(self):
          self.runable = False
  
  def microbreak():
      root = Tkinter.Tk()
      Tkinter.Frame(root, width=250, height=100).pack()
      Tkinter.Label(root, text='Hello').place(x=10, y=10)
      threading.Timer(3.0, root.destroy).start()
      root.mainloop()
      return()
  
  thread = RepeatEvery(6, microbreak)
  thread.start()
  </code></pre>
  
  <p>This gives me the first break notification but fails before giving me a second break notification.</p>
  
  <blockquote>
    <p>Tcl_AsyncDelete: async handler deleted by the wrong thread</p>
    
    <p>fish: Job 1, “python Documents/python/timer/timer.py ” terminated by
    signal SIGABRT (Abort)</p>
  </blockquote>
  
  <p>Any ideas? I'm happy to use something other than tkinter for gui-stuff or something other than threading to implement the time stuff.</p>
  
  <hr>
  
  <p>Based on the answers below, my new working script is as follows:</p>
  
  <pre><code>import Tkinter as Tk
  import time
  
  class Window:
      def __init__(self):
          self.root = None
          self.hide = 10 #minutes
          self.show = 10 #seconds
  
      def close(self):
          self.root.destroy()
          return
  
      def new(self):
          self.root = Tk.Tk()
          self.root.overrideredirect(True)
          self.root.geometry("{0}x{1}+0+0".format(self.root.winfo_screenwidth(), self.root.winfo_screenheight()))
          self.root.configure(bg='black')
          Tk.Label(self.root, text='Hello', fg='white', bg='black', font=('Helvetica', 30)).place(anchor='center', relx=0.5, rely=0.5)
          #Tk.Button(text = 'click to end', command = self.close).pack()
          self.root.after(self.show*1000, self.loop)
  
      def loop(self):
          if self.root:
              self.root.destroy()
          time.sleep(self.hide*60)
          self.new()
          self.root.mainloop()
          return
  
  Window().loop()
  </code></pre>