tkinter (python): assign class method to a key
问题 In my simple code, a red ball is falling down in a straight line (that's working). When I push the right arrow key, I want the ball to also move in right direction. This is not working, however. What am I doing wrong? from tkinter import * root = Tk() canvas = Canvas(root, height=400, width=500, background='black') canvas.pack() class Bird: def __init__(self, canvas, coords): self.canvas = canvas self.coords = coords self.bird = canvas.create_rectangle(coords, fill='red') def gravity(self):