# -*- coding: utf-8 -*- import turtle win = turtle.Screen() tt = turtle.Turtle() win.bgcolor('lightgreen') tt.speed(0) ###### class dashline: def __init__(self, sections, width, color): self.sections = sections self.width = width self.color = color def draw(self, length): sec = int(length/self.sections) tt.pensize(self.width) tt.color(self.color) for i in range(self.sections): tt.fd(sec/2.0) tt.pu() tt.fd(sec/2.0) tt.pd() def setColor(self, newColor): self.color = newColor def drawArrow(self, length): sec = int(length/self.sections) tt.pensize(self.width) tt.color(self.color) for i in range(self.sections): tt.fd(sec/2.0) tt.lt(45) tt.bk(sec/3.0) tt.pu() tt.fd(sec/3.0) tt.down() tt.rt(90) tt.bk(sec/3.0) tt.pu() tt.fd(sec/3.0) tt.lt(45) tt.fd(sec/2.0) tt.pd() dline = dashline(5, 3, 'blue') tt.fd(100) dline.drawArrow(100) tt.up() tt.home() tt.left(60) tt.down() dline.drawArrow(80) tt.up() tt.home() tt.rt(60) tt.down() dline.drawArrow(80) tt.up() tt.home() tt.left(180) dline.setColor('red') dline.drawArrow(300) ###### win.exitonclick()