import tkinter as tk """ Create a canvas with two shapes and bind events to movements """ root = tk.Tk() root.geometry('800x600') root.title('Canvas Demo - Oval') canvas = tk.Canvas(root, width=600, height=400, bg='white') canvas.pack(anchor=tk.CENTER, expand=True) canvas.focus_set() points = ( (50, 150), (200, 300), ) shape = canvas.create_oval(*points, fill='purple') line = canvas.create_line(50,50,100,100, fill='blue') def leftcircle(event): x=-10 y=0 canvas.move(shape,x,y) def rightcircle(event): x=10 y=0 canvas.move(shape,x,y) def leftline(event): x=-10 y=0 canvas.move(line,x,y) def rightline(event): x=10 y=0 canvas.move(line,x,y) canvas.bind("", leftcircle) canvas.bind("", rightcircle) canvas.bind("", leftline) canvas.bind("", rightline) root.mainloop()