title: Loop that will check network connection using tkinter and urllib
body: <pre><code>import urllib
  import urllib.request as url
  from tkinter import *
  
  master = Tk()
  master.geometry("250x50")
  master.resizable(False, False)
  master.config(bg="#4b4b4b")
  master.overrideredirect(True)
  master.wm_geometry("-0-40")
  
  connectStatus = Label(bg="yellow", fg="#fff", width=28, height=2, text="Pending", font="Bahnscrift 10")
  connectStatus.place(x=10,y=8)
  
  def runRefresh():
      print("Checking")
      connectStatus.config(bg="yellow", fg="#fff", width=28, height=2, text="Pending", font="Bahnscrift 10")
      attemptConnect()
  
  def attemptConnect():
      try:
          ping = url.urlopen("https://stackoverflow.com", timeout=1)
          connectStatus.config(text="Connected", font="Bahnscrift 10", bg="green")
          return True
  
      except urllib.error.URLError:
          connectStatus.config(text="Not Connected", bg="#ff4d4d", font="Bahnscrift 10")
          return False
  
  master.after(1000, runRefresh)
  master.mainloop()
  </code></pre>
  
  <p>Hello. I'm using the following code - what this code does currently is runs the attemptConnect() function and changes the Label accordingly (depending on what happens in the try/except). The problem I'm having is getting this to loop every couple of seconds.. I can't figure out a way to do it. I've tried using tkinter's after, but nothing..</p>
  
  <p>So my question - How can I get this to run the attemptConnect() every couple of seconds?</p>