Keypress Input
John McKenzie
davros at bellaliant.net
Mon Jun 15 01:15:31 EDT 2015
from Tkinter import *
from blinkstick import blinkstick
led = blinkstick.find_first()
timered = 0
timeyellow = 0
timeblue = 0
colour = None
root = Tk()
root.title('eFlag 1')
def red1(event):
colour = 1
def yellow1(event):
colour = 2
def blue1(event):
colour = 3
root.bind_all('r', red1)
root.bind_all('b', blue1)
root.bind_all('y', yellow1)
root.mainloop()
while colour == None:
led.pulse(red=0, green=255, blue=0, repeats=1, duration=5000,
steps=50)
while colour == 1:
led.pulse(red=255, green=0, blue=0, repeats=1, duration=3000,
steps=50)
timered += 1
while colour == 2:
led.pulse(red=255, green=255, blue=0, repeats=1, duration=3000,
steps=50)
timeyellow += 1
while colour == 3:
led.pulse(red=0, green=0, blue=255, repeats=1, duration=2000,
steps=50)
timeblue += 1
def exit_handler():
print '\033[0;41;37mRed Team:\033[0m ', timered
print '\033[0;43;30mYellow Time:\033[0m ', timeyellow
print '\033[0;44;37mBlue Time:\033[0m ', timeblue
flog = open('flag1log.text', 'a')
flog.write(timestamp + '\n' + 'Red Team: ' + str(timered) + '\n' +
'Yellow Team: ' + str(timeyellow) + '\n' + 'Blue Team: ' + str(timeblue)
+ '\n')
flog.close()
atexit.register(exit_handler)
More information about the Python-list
mailing list