Skip to content

Instantly share code, notes, and snippets.

@kriwil
Created May 28, 2015 00:56
Show Gist options
  • Save kriwil/96439ccc58f5868ae622 to your computer and use it in GitHub Desktop.
Save kriwil/96439ccc58f5868ae622 to your computer and use it in GitHub Desktop.
import random
from Tkinter import *
class Application(Frame):
wait = 50
def __init__(self, master=None):
Frame.__init__(self, master)
self.master = master
self.pack()
self.createWidgets()
master.after(self.wait, self.animate)
def createWidgets(self):
self.first = Label(self)
self.first["text"] = "0"
self.first["height"] = 10
self.first["width"] = 20
self.first["font"] = ("sans-serif", 30)
self.first.pack({"side": "left"})
def update_first(self):
number = random.randint(0, 9)
self.first["text"] = str(number)
def animate(self):
self.update_first()
self.master.after(self.wait, self.animate)
root = Tk()
app = Application(master=root)
app.mainloop()
root.destroy()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment