| | |
A Second Counter using Tkinter GUI
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Using count() from Python's itertools module and the Tkinter GUI toolkit's after() function, you can create a simple counter that counts up the seconds until the Stop button is pressed.
# a second counter using Tkinter # tested with Python25 by vegaseat 17aug2007 import Tkinter as tk from itertools import count def start_counter(label): counter = count(0) def update_func(): label.config(text=str(counter.next())) label.after(1000, update_func) # 1000ms update_func() root = tk.Tk() root.title("Counting Seconds") label = tk.Label(root, fg="red") label.pack() start_counter(label) button = tk.Button(root, text='Stop', width=30, command=root.destroy) button.pack() root.mainloop()
Similar Threads
- XML gui Tkinter (Python)
- Constructing a simple GUI with Tkinter (Python)
- Taking a variable out of a Tkinter GUI (Python)
- Exit a Tkinter GUI Program (Python)
- Tkinter GUI Issues: (Python)
| Thread Tools | Search this Thread |
accessdenied apache application argv array beginner book builtin change color converter countpasswordentry curved dan08 dictionary dynamic edit enter examples file filename float format function gui homework import inches input java keyboard lapse library line lines linux list lists loop microphone mouse movingimageswithpygame mysql mysqlquery newb number numbers numeric output parameters parsing path phonebook plugin port prime programming projects py2exe pygame pyopengl pysimplewizard python random recursion redirect remote reverse scrolledtext session simple smtp software sprite statictext string strings syntax table tennis terminal text textarea thread threading time tkinter tlapse trick tuple tutorial ubuntu unicode unit urllib urllib2 variable windows wordgame wxpython



