import tkinter import turtle root = tkinter.Tk() c = tkinter.Canvas(root, width=200, height=200) c.pack() c.create_rectangle(0, 0, 200, 200, fill="blue") ts = turtle.TurtleScreen(c) ts.bgcolor("blue") pen = turtle.RawTurtle(ts) def draw(): ts.clearscreen() # Gets rid of the turtle # Move to starting location. ts.bgcolor("blue") pen.pencolor("blue") pen.setheading(180) pen.forward(50) pen.setheading(90) pen.forward(50) # Draw square pen.pencolor("white") pen.setheading(0) pen.forward(100) pen.setheading(270) pen.forward(100) pen.setheading(180) pen.forward(100) pen.setheading(90) pen.forward(100) # Return home for next draw. pen.pencolor("blue") pen.home() def clear(): ts.clearscreen() ts.bgcolor("blue") draw = tkinter.Button(root, text="Draw", command=draw) clear = tkinter.Button(root, text="Clear", command=clear) draw.pack() clear.pack() tkinter.mainloop()