Skip to content

Instantly share code, notes, and snippets.

@vgmoose
Created May 19, 2013 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vgmoose/5607231 to your computer and use it in GitHub Desktop.
Save vgmoose/5607231 to your computer and use it in GitHub Desktop.
from Tkinter import *
import time, thread
master = Tk()
master.title("Switch test")
w = Canvas(master, width=200, height=200)
w.pack()
w.create_rectangle(0, 0, 200, 100, fill="white")
w.create_rectangle(0, 200, 200, 100, fill="white")
def on(event):
w.create_rectangle(0, 200, 200, 100, fill="white")
w.create_rectangle(0, 0, 200, 100, fill="yellow")
thread.start_new_thread ( turnback, ())
def off(event):
w.create_rectangle(0, 0, 200, 100, fill="white")
w.create_rectangle(0, 200, 200, 100, fill="yellow")
thread.start_new_thread ( turnback, ())
def turnback():
time.sleep(3)
w.create_rectangle(0, 0, 200, 100, fill="white")
w.create_rectangle(0, 200, 200, 100, fill="white")
w.bind_all('<space>', on)
w.bind_all('<Return>', off)
master.mainloop( )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment