Q:

Updating Tkinter window

I've got a simple Tkinter window that shows if a production line is up or down and if down for how long. However, I can't figure out how to get it to update the labels of each line. I tried to use .after() to check for changes and then call create_label() but it just adds another label, and calling root.update_idletasks() doesn't do anything. I've also tried using StringVar() but I can't get that working either.
import Tkinter as tk
import tkFont
import time

class Line():
   def __init__(self, line_name):
      self.name = line_name
      self.label = None
      self.start = None

   def get_down_time(self):
      #return status of line
      if self.start:
         return time.clock()-self.start, 'red'
      else:
         return 'Running', 'green'

   def create_label(self, parent):
      status, color = self.get_down_time()
      font = tkFont.Font(family="FixedSys", size=8)
      self.label = tk.Label(parent, text = '{:>7} {:>9}'.format(self.name+':', status), bg=color, fg='black', height = 1, justify=tk.LEFT, anchor=tk.NW, relief=tk.RAISED, font = font)
      self.label.pack(fill=tk.X, expand=False)

def initUI(root, lines):

   root.title("Line Status")

   for line in lines.values():    #Create all labels
      line.create_label(root)     

def check_for_changes(lines, root):

   inp = raw_input('>>> ').replace('\n','')

   if inp in lines.keys():     #check if input is a line and update value if so
      if lines[inp].start:
         lines[inp].start = None
      else:
         lines[inp].start = time.clock()

   #lines[inp].create_label(root)     #Creates new label
   #root.update_idletasks()     #Does nothing
   root.after(1000, check_for_changes, lines, root) 

def main():

   lines = {'1': Line('1'), '2': Line('2'), '3':Line('3')}

   root = tk.Tk()
   root.geometry("175x300+300+300")

   initUI(root, lines)     #create window with labels 
   root.after(1000, check_for_changes, lines, root)
   root.mainloop()

if __name__ == '__main__':
   main() 

A:

Each line object has a label as a child. You can simply call configure on the label object to change it. There's no need to use a StringVar:
lines[inp].label.configure(text="...", background="...")

