Python 如何在Tkinter画布上同时移动多个对象?

Python 如何在Tkinter画布上同时移动多个对象?,python,tkinter,tkinter-canvas,Python,Tkinter,Tkinter Canvas,我有这段代码,它移动两个Tkinter画布对象中的一个。如何使用canvas.move使其同时移动 canvas.create_oval(100, 105, 150, 150, fill = 'light blue', \ outline = 'green') canvas.create_oval(200, 205, 150, 150, fill= 'light blue', \ outline = 'green'

我有这段代码,它移动两个Tkinter画布对象中的一个。如何使用canvas.move使其同时移动

canvas.create_oval(100, 105, 150, 150, fill = 'light blue', \
                    outline = 'green')

canvas.create_oval(200, 205, 150, 150, fill= 'light blue', \
                    outline = 'green')

tkinter.update()

for x in range (1, 100):
    canvas.move(1, 5, 0)
    tkinter.update()
    time.sleep(0.05)

这听起来像是一份工作。您可以类似地标记两个对象,然后要求画布以这种方式移动所有标记的对象:

import tkinter as tk
import time

root = tk.Tk()

canvas = tk.Canvas(root)
canvas.pack()

canvas.create_oval(100, 105, 150, 150, tags="Bob", fill='light blue', outline='green')
canvas.create_oval(200, 205, 150, 150, tags="Bob", fill='light blue', outline='green')

for _ in range(50):
    canvas.move("Bob", 5, 0)
    canvas.update()
    time.sleep(0.05)

root.mainloop()