canva.addtag_closest('player', x, y) p_x = x canva = Canvas(root, width=600, height=400) for x in (50, 100, 150, 200, 250, 300, 350, 400, 450, 500): for y in (20, 40, 60, 80, 100): boxes += 1 canva.create_rectangle(x + 3, y + 3, x + 47, y + 17, width=3, outline='black', fill='cyan') canva.addtag_closest('box%s_%s' % (x, y), x + 25, y + 10) canva.place(x=-1, y=-1) plot_player(p_x) def ball(): while True: plot_ball(b_x, b_y) sleep(0.005) th = Thread(target=ball, daemon=True) root.after_idle(th.start) root.bind('<Left>', left)