title: How to loop this code?
body: <p>I have trying to loop this but fail everytime.
  It´s the def create_widgets I try to loop. So I got a GUI that show a red button/box as soon something goes offline.</p>
  
  <p>This is the code I tried to use.</p>
  
  <pre><code>from tkinter import *
  
  class Application(Frame):
  """ GUI """
  
  def __init__(self, master):
      """ Initialize the Frame"""
      Frame.__init__(self,master)
      self.grid()
      self.create_widgets()
  
  def create_widgets(self):
      """Create button. """
      import os
      #Router
      self.button1 = Button(self)
      self.button1["text"] = "Router"
      self.button1["fg"] = "white"
      self.button1.grid(padx=0,pady=5)
      #Ping
      hostname = "10.18.18.1"
      response = os.system("ping -n 1 " + hostname)
      #response
      if response == 0:
          self.button1["bg"] = "green"
      else:
          self.button1["bg"] = "red"
  
  root = Tk()
  root.title("monitor")
  root.geometry("500x500")
  
  app = Application(root)
  
  root.mainloop()
  </code></pre>