def beginfillhandler()cmd beginfillcommand(fillcolor get()cmd draw(theturtleself graphicscommands append(cmd beginfillbutton tkinter button(sidebartext "begin fill"command=beginfillhandlerbeginfillbutton pack(fill=tkinter both def endfillhandler()cmd endfillcommand(cmd draw(theturtleself graphicscommands append(cmd endfillbutton tkinter button(sidebartext "end fill"command=endfillhandlerendfillbutton pack(fill=tkinter both penlabel tkinter label(sidebar,text="pen is down"penlabel pack( def penuphandler()cmd penupcommand(cmd draw(theturtlepenlabel configure(text="pen is up"self graphicscommands append(cmd penupbutton tkinter button(sidebartext "pen up"command=penuphandlerpenupbutton pack(fill=tkinter both def pendownhandler()cmd pendowncommand(cmd draw(theturtlepenlabel configure(text="pen is down"self graphicscommands append(cmd pendownbutton tkinter button(sidebartext "pen down"command=pendownhandlerpendownbutton pack(fill=tkinter both here is another event handler this one handles mouse clicks on the screen def clickhandler( , )when mouse click occursget the widthsize entry value and set the width of the pen to the widthsize value the float(widthsize get()is needed because the width is floatbut the entry widget stores it as string cmd gotocommand( , ,float(widthsize get()),pencolor get()cmd draw(theturtleself graphicscommands append(cmdscreen update(screen listen( here is how we tie the clickhandler to mouse clicks screen onclick(clickhandler def draghandler( , )cmd gotocommand( , ,float(widthsize get()),pencolor get()cmd draw(theturtleself graphicscommands append(cmdscreen update(screen listen( theturtle ondrag(draghandler the undohandler undoes the last command by removing it from the sequence and then redrawing the entire picture def undohandler()if len(self graphicscommands self graphicscommands removelast(theturtle clear(theturtle penup(theturtle goto( , this copy belongs to 'acha