Advertisement
Ruddog

GUI Counter

May 8th, 2017
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.42 KB | None | 0 0
  1. import tkinter
  2. from tkinter import *
  3. print("Step0")
  4. # just init some vars
  5. remaining = 0                
  6. secs = 0
  7. root = tkinter.Tk()
  8. prompt = StringVar()
  9. print("Contents of prompt is :" + str(prompt))
  10. print("Contentes of StringVar is " + str(StringVar))
  11. def snooze (secs):
  12.   print("Step1")
  13.   """
  14.  Snoozes for the given number of seconds. During the snooze, a progress
  15.  dialog is launched notifying the
  16.  """
  17.   #################################################
  18.   def decrement_label ():
  19.     print("Start Step2")
  20.     global remaining, prompt
  21.     print("Before line : remaining = remaining -1" + str(remaining) + str(prompt))
  22.     remaining = remaining - 1
  23.     print("After line : remaining = remaining -1" + str(remaining))
  24.     print("Looping Step2A")
  25.     prompt.set('Snoozing %d sec(s)' % remaining)
  26.     label1.update_idletasks()
  27.     print("Looping Step2B")
  28.     if not remaining:
  29.       print("end ... ")
  30.       root.destroy()
  31.   #################################################
  32.   print("Step3")
  33.   global remaining
  34.   prompt.set("hello")
  35.   print("Step3a")
  36.   label1 = tkinter.Label(root, textvariable=prompt, width=30)
  37.   print("Step3b")
  38.   label1.pack()
  39.   print("Step3c")
  40.   remaining = secs
  41.   print("Step3d")
  42.   # Start=1 Stop=5 Step=1
  43.   for i in range(1, secs + 1):
  44.     print("i in range = " + str(i))
  45.     print("Step4")
  46.     root.after(i * 1000, decrement_label )
  47.     print("Step4a")
  48. snooze(10)
  49. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement