""" smilTimer.py use tk to build a quick timer for SMIL and other technologies """ from Tkinter import * import time class App: def __init__(self, parent): self.setupUI(parent) self.times = [0] self.begin = time.time() def setupUI(self, parent): self.frame = Frame(parent, bg = "blue") self.frame.grid() self.lblOutput = Label(self.frame, bg = "blue", fg = "white", font = "courier 20 bold", text = "Use buttons for control") self.lblOutput.grid() self.btnBegin = Button(self.frame, text = "begin", width = 30, command = self.begin) self.btnBegin.grid() self.btnInterval = Button(self.frame, text = "interval", width = 30, command = self.interval) self.btnInterval.grid() self.btnSmil = Button(self.frame, text = "create smil", width = 30, command = self.createSmil) self.btnSmil.grid() self.lblTimes = Label(self.frame, bg = "white", width = 60) self.lblTimes.grid() for item in self.lblOutput.config(): print item def begin(self): self.begin = time.time() self.times = [0] self.showTimes() def interval(self): now = time.time() elapsed = now - self.begin self.times.append(elapsed) self.showTimes() def createSmil(self): #print "in createSmil" self.lblTimes["text"] = """ SMIL or other synchronized XML content will go here """ def showTimes(self): counter = 0 numPerLine = 8 output = "" for moment in self.times: output += "%.2f\t" % moment counter += 1 if counter >= numPerLine: counter = 0 output += "\n" #print "" #print output self.lblTimes["text"] = output def main(): root = Tk() root.title("SMIL Timer") app = App(root) root.mainloop() if __name__ == "__main__": main()