here are few notes about how the program works firstevery time the mouse is moved over the canvasthe mouse_motion_event function is called this function prints the mouse' current coordinates which are contained in the event attributes and the wheel_event function is called whenever the user uses the mouse (scrollingwheel the event attribute delta contains information about how quickly and in what direction the wheel was moved we just stretch or shrink the rectangle based on whether the wheel was moved forward or backward the _event function is called whenever the user presses the left mouse button the function changes the color of the rectangle whenever the rectangle is clicked there is global variable here called _drag that is important it is set to true whenever the user is dragging the rectangle when dragging is going onthe left mouse button is down and the _event function is continuously being called we don' want to keep changing the color of the rectangle in that casehence the if statement the dragging is accomplished mostly in the _motion_event functionwhich is called whenever the left mouse button is down and the mouse is being moved it uses global variables that keep track of what the mouse' position was the last time the function was calledand then moves the rectangle according to the difference between the new and old position when the dragging is downthe left mouse button will be released when that happensthe _release_event function is calledand we set the global _drag variable accordingly the focus_set method is needed because the canvas will not recognize the mouse wheel events unless the focus is on the canvas one problem with this program is that the user can modify the rectangle by clicking anywhere on the canvasnot just on rectangle itself if we only want the changes to happen when the mouse is over the rectanglewe could specifically bind the rectangle instead of the whole canvaslike belowcanvas tag_bind(rect' _motion_event