我正在尝试在 tkinter 窗口上移动画布圆圈。我正在使用 canvas.move,但它只是让对象重新出现在新位置。我想真正看到它旅行。有没有办法做到这一点?我有以下内容:
def move_to(self, user_id, old_location, new_location):
self.user_list[user_id].set_location(new_location)
user_canvas_id = self.user_id_dict[user_id]
row_delta = new_location[ROW_INDEX] - old_location[ROW_INDEX]
col_delta = new_location[COL_INDEX] - old_location[COL_INDEX]
self.canvas.move(user_canvas_id, row_delta, col_delta)
def roaming_handler(self, user_id):
row = randrange(1, self.number_of_events * 125)
col = randrange(1, self.number_of_events * 125)
user_location = self.user_list[user_id].get_location()
self.move_to(user_id, user_location, (row, col))
当时的模拟中还发生了许多其他事情,其中许多人会在某个时候或另一个时候称之为这个。