title: Increasing integers at specific time with elapsed time
body: <p>I'm trying to make a program that will work as an "infomercial" in a separate window.</p>
  
  <p>What i have are two integers (x and y) that both increase at the same time, in this case every 5 seconds. With the increasing values i need a timer displayed at the same time, that can show the elapsed time of how long the program has been running. I want to be albe to start and pause the program
  So far i have an infinite while loop running where the values are increased every 5 seconds with <code>time.sleep(5)</code>. I have tried implementing a timer in the form of a <code>time.time()</code>, and get it to work with the increments. I have also added buttons but don't work. I'm using <code>tkinter</code> as gui obtion.</p>
  
  <p>How am i supposed to make it work? with threading?</p>
  
  <pre><code>import time
  from tkinter import *
  import math
  
  usage = 0
  yearly = 0
  cubik = 0
  price = 0
  
  root = Tk()
  root.title("Usage of fluid")
  
  root.geometry("300x400")
  
  var = IntVar()
  var1 = IntVar()
  var2 = StringVar()
  var3 = StringVar()
  var4 = StringVar()
  
  def update_timeText():
      current= time.strftime("%H:%M:%S")
      timeText.configure(text=current)
      root.after(1000, update_timeText)
  
  def start():
      global state
      state = True
  
  def pause():
      global state
      state = False
  
  def exist():
      root.destroy()
  
  
  frame = LabelFrame(root, text="Liter", font=30)
  frame.pack(fill = "both", expand="yes")
  
  l = Label(frame, textvariable=var, font=20)
  l.pack(pady = 3)
  
  frame2 = LabelFrame(root, text="price from use", font=30)
  frame2.pack(fill = "both", expand= "yes")
  
  l2 = Label(frame2, textvariable=var1, font=16)
  l2.pack(side = LEFT)
  
  l3 = Label(frame2, text="dollars", font=16)
  l3.pack(side=LEFT)
  
  frame3 = LabelFrame(root, text="yearly", font=30)
  frame3.pack(fill = "both", expand="yes")
  
  m3 = Label(frame3, textvariable=var2, font=16, wraplength=0)
  m3.pack(side=TOP)
  
  l4 = Label(frame3, text="Liter", font=16)
  l4.pack(side=TOP)
  
  l5 = Label(frame3, text="m3", font=16)
  l5.pack(side=BOTTOM, fill="both")
  
  m4 = Label(frame3, textvariable=var3, font=16, wraplength=0)
  m4.pack(side=BOTTOM)
  
  frame4 = LabelFrame(root, text='runtime', font=30)
  frame4.pack(fill = "both", expand="yes")
  
  timeText= Label(frame4, text="", font=16)
  timeText.pack()
  
  startButton = Button(frame4, text='Start', command=start)
  startButton.pack()
  
  pauseButton = Button(frame4, text='Pause', command=pause)
  pauseButton.pack()
  
  quitButton = Button(frame4, text='Quit', command=quit)
  quitButton.pack()
  
  
  while True:
      var.set(usage)
      usage += 300
      var1.set(round(price,1))
      price+= 10
      var2.set(yearly)
      var3.set(round(cubik,1))
      yearly += 300
      cubik += 0.1
      time.sleep(5)
      update_timeText()
      root.update_idletasks()
  
  ##update_timeText()
  ##root.mainloop()
  </code></pre>