
December 5th, 2012, 12:00 AM
|
|
Contributing User
|
|
Join Date: May 2009
Posts: 294
  
Time spent in forums: 3 Days 18 h 53 m 25 sec
Reputation Power: 7
|
|
Your code modified to print which key was pressed, Up, Down, etc. And a tutorial on the Canvas module
Code:
def to_key(event):
print event.keysym
key1 = 1
Controls = tkinter.Tk()
Controls.title("Color")
Controls.minsize(100, 100)
Controls.bind("<KeyPress>", to_key)
#cv = tkinter.Canvas(Controls, bg = "gray")
#cv.pack(side = tkinter.LEFT)
#t = RawTurtle(cv)
#t.pensize(3)
w = tkinter.Label(Controls, text="Arrow Keys - Move")
w.pack()
def k1():
global key1
key1 +=1
while key1 % 2 == 0:
t.pencolor(random.choice(colors))
t.forward(5)
#onkey(k1, "Up")
#listen()
Controls.mainloop()
|