import subprocess
import os 
import time
from tkinter import *
root=Tk()
textbox=Text(root)
textbox.pack()
def redirector(inputStr):
    textbox.insert(INSERT, inputStr)
def address_ping():
        '''
        DOCSTRING -> Ip addresses in servers.txt are
                     192.168.0.1     192.168.0.26
        '''
        while True:
            with open('servers.txt', 'r') as f:
                for ip in f:
                    result=subprocess.Popen(["ping", "-c", "7", "-n", "-W", "2", ip],stdout=f, stderr=f).wait()
                    if result:
                        print("ip address " + ip, "is inactive")
                        sys.stdout.write = redirector
                    else:
                        print("ip address " + ip, "is active")
                        sys.stdout.write = redirector
                    pass    
address_ping()        
root.mainloop()
I am writing a piece of code here that will send a ping to an IP address and return a result. It works fine on the CLI, however I wish to "print" it to a Text widget using Tkinter. I am at a point where it will send it to the Text widget GUI but it only makes itself visible after I interrupt the program. I want to have a rolling output to the GUI text area as the pings progress through a loop.