lukeanders70
lukeanders70

Reputation: 73

moving multiple objects on a Tkinter canvas simultaneously

I have a Tkinter Canvas with a lot of pictures on it, Is there any way to move them all easily? I know about 'canvas.move' but, its very repetitive and clustered when using it for many objects. Is there a way to move all objects on a canvas at the same time or, perhaps, combine all the pictures into a single object(using python)? Thanks in advance.

Upvotes: 1

Views: 2787

Answers (1)

A. Rodas
A. Rodas

Reputation: 20679

You can pass the constant ALL to the move method:

from Tkinter import *

root = Tk()
canvas = Canvas(root, width=200, height=200)
canvas.create_rectangle(10, 10, 60, 60)
canvas.create_rectangle(70, 70, 120, 120)
canvas.pack()
canvas.move(ALL, 50, 50)
root.mainloop()

Upvotes: 1

Related Questions