Create a gist now

Instantly share code, notes, and snippets.

@kriwil /rd.py
Created May 28, 2015

What would you like to do?
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