Skip to content

Instantly share code, notes, and snippets.

@DeflatedPickle
Last active July 14, 2019 07:21
Show Gist options
  • Save DeflatedPickle/82d8e044aa03b3644ff10353754b8f59 to your computer and use it in GitHub Desktop.
Save DeflatedPickle/82d8e044aa03b3644ff10353754b8f59 to your computer and use it in GitHub Desktop.
Endlessly generates a random number and shows it in a Tkinter window.
import tkinter as tk
import random
class Random(tk.Tk):
def __init__(self):
tk.Tk.__init__(self)
self.title("Random")
self.variable = tk.IntVar()
label = tk.Label(self, textvariable=self.variable, font=("courier", 69))
label.pack(fill="both", expand=True)
self.do_random()
def do_random(self, interval=100):
self.variable.set(random.randint(0, 99999))
self.after(interval, self.do_random)
def main():
r = Random()
r.mainloop()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment