screen update( filemenu add_command(label="load into ",command=addtofile the write function writes an xml file to the given filename def write(filename)file open(filename" "file write('\ 'file write('\ 'for cmd in self graphicscommandsfile write('+str(cmd)+"\ " file write('\ ' file close( def savefile()filename tkinter filedialog asksaveasfilename(title="save picture as "write(filename filemenu add_command(label="save as ",command=savefile filemenu add_command(label="exit",command=self master quit bar add_cascade(label="file",menu=filemenu this tells the root window to display the newly created menu bar self master config(menu=bar here several widgets are created the canvas is the drawing area on the left side of the window canvas tkinter canvas(self,width= ,height= canvas pack(side=tkinter left by creating rawturtlewe can have the turtle draw on this canvas otherwisea rawturtle and turtle are exactly the same theturtle turtle rawturtle(canvas this makes the shape of the turtle circle theturtle shape("circle"screen theturtle getscreen( this causes the application to not update the screen unless screen update(is called this is necessary for the ondrag event handler below without itthe program bombs after dragging the turtle around for while screen tracer( this is the area on the right side of the window where all the buttonslabelsand entry boxes are located the pad creates some empty space around the side the side puts the sidebar on the right side of the this frame the fill tells it to fill in all space available on the right side sidebar tkinter frame(self,padx= ,pady= sidebar pack(side=tkinter rightfill=tkinter both this is label widget packing it puts it at the top of the sidebar pointlabel tkinter label(sidebar,text="width"pointlabel pack( this entry widget allows the user to pick width for their lines with the widthsize variable below you can write widthsize get(to get the contents of the entry widget and widthsize set(valto set the value of the entry widget to val initially the widthsize is set to str( is needed because the entry widget must be given string widthsize tkinter stringvar(widthentry tkinter entry(sidebar,textvariable=widthsizethis copy belongs to 'acha