self oncleardelete all canvas bind(''self onmovemove latest self canvas canvas self drawn none self kinds [canvas create_ovalcanvas create_rectangledef onstart(selfevent)self shape self kinds[ self kinds self kinds[ :self kinds[: self start event self drawn none start dragout def ongrow(selfevent)delete and redraw canvas event widget if self drawncanvas delete(self drawnobjectid self shape(self start xself start yevent xevent yif traceprint(objectidself drawn objectid def onclear(selfevent)event widget delete('all'use tag all def onmove(selfevent)if self drawnmove to click spot if traceprint(self drawncanvas event widget diffxdiffy (event self start )(event self start ycanvas move(self drawndiffxdiffyself start event if __name__ ='__main__'canvaseventsdemo(mainloop(this script intercepts and processes three mouse-controlled actionsclearing the canvas to erase everything on the canvasthe script binds the double left-click event to run the canvas' delete method with the all tag--againa built-in tag that associates every object on the screen notice that the canvas widget clicked is available in the event object passed in to the callback handler (it' also available as self canvasdragging out object shapes pressing the left mouse button and dragging (moving it while the button is still pressedcreates rectangle or oval shape as you drag this is often called dragging out an object--the shape grows and shrinks in an elastic rubber-band fashion as you drag the mouse and winds up with final size and location given by the point where you release the mouse button to make this work in tkinterall you need to do is delete the old shape and draw another as each drag event firesboth delete and draw operations are fast enough to achieve the elastic drag-out effect of courseto draw shape to the current canvas