Python turtle 模块,RawTurtle() 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用turtle.RawTurtle()

项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def main():
    root = TK.Tk()
    cv1 = TK.Canvas(root, width=300, height=200, bg="#ddffff")
    cv2 = TK.Canvas(root, width=300, height=200, bg="#ffeeee")
    cv1.pack()
    cv2.pack()

    s1 = TurtleScreen(cv1)
    s1.bgcolor(0.85, 0.85, 1)
    s2 = TurtleScreen(cv2)
    s2.bgcolor(1, 0.85, 0.85)

    p = RawTurtle(s1)
    q = RawTurtle(s2)

    p.color("red", (1, 0.85, 0.85))
    p.width(3)
    q.color("blue", (0.85, 0.85, 1))
    q.width(3)

    for t in p,q:
        t.shape("turtle")
        t.lt(36)

    q.lt(180)

    for t in p, q:
        t.begin_fill()
    for i in range(5):
        for t in p, q:
            t.fd(50)
            t.lt(72)
    for t in p,q:
        t.end_fill()
        t.lt(54)
        t.pu()
        t.bk(50)

    return "EVENTLOOP"
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def main():
    root = TK.Tk()
    cv1 = TK.Canvas(root, width=300, height=200, bg="#ddffff")
    cv2 = TK.Canvas(root, width=300, height=200, bg="#ffeeee")
    cv1.pack()
    cv2.pack()

    s1 = TurtleScreen(cv1)
    s1.bgcolor(0.85, 0.85, 1)
    s2 = TurtleScreen(cv2)
    s2.bgcolor(1, 0.85, 0.85)

    p = RawTurtle(s1)
    q = RawTurtle(s2)

    p.color("red", (1, 0.85, 0.85))
    p.width(3)
    q.color("blue", (0.85, 0.85, 1))
    q.width(3)

    for t in p,q:
        t.shape("turtle")
        t.lt(36)

    q.lt(180)

    for t in p, q:
        t.begin_fill()
    for i in range(5):
        for t in p, q:
            t.fd(50)
            t.lt(72)
    for t in p,q:
        t.end_fill()
        t.lt(54)
        t.pu()
        t.bk(50)

    return "EVENTLOOP"
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def main():
    root = TK.Tk()
    cv1 = TK.Canvas(root, width=300, height=200, bg="#ddffff")
    cv2 = TK.Canvas(root, width=300, height=200, bg="#ffeeee")
    cv1.pack()
    cv2.pack()

    s1 = TurtleScreen(cv1)
    s1.bgcolor(0.85, 0.85, 1)
    s2 = TurtleScreen(cv2)
    s2.bgcolor(1, 0.85, 0.85)

    p = RawTurtle(s1)
    q = RawTurtle(s2)

    p.color("red", (1, 0.85, 0.85))
    p.width(3)
    q.color("blue", (0.85, 0.85, 1))
    q.width(3)

    for t in p,q:
        t.shape("turtle")
        t.lt(36)

    q.lt(180)

    for t in p, q:
        t.begin_fill()
    for i in range(5):
        for t in p, q:
            t.fd(50)
            t.lt(72)
    for t in p,q:
        t.end_fill()
        t.lt(54)
        t.pu()
        t.bk(50)

    return "EVENTLOOP"
项目:Frida    作者:Alejandro-Valdes    | 项目源码 | 文件源码
def drawBrush(self, fig_param_stack, res_address):
        """Crea un pincel sobre el canvas actual 

        args:
            fig_param_stack -- list(params) : lista de parámetros de inicialización
            res_address -- int : dirección donde guardar pincel
        """

        color = self.mem.getValue(fig_param_stack.pop())

        # create a turtle object
        ttl = turtle.RawTurtle(self.canvas)

        try:
            ttl.color(color)
        except:
            try:
                color = g.colorDict[color]
                ttl.color(color)
            except KeyError:
                self.caller.print('Error: color ' + color + ' no me sirve')
                self.caller.running = False
                return

        ttl.speed('fastest')
        ttl.shape('circle')

        self.mem.setValue(ttl, int(res_address))
项目:repo    作者:austinHeisleyCook    | 项目源码 | 文件源码
def __init__(self, master):
        root.title("my drawing app  ")
        self.canvas = Canvas(master, bg="white", width=500, height=500, highlightthickness=0)
        self.canvas.grid(column=3, row=4)
        self.t = turtle.RawTurtle(self.canvas)
        self.t.position()
        self.x  =  00.00
        self.y  = 00.00
        (self.x,self.y)
        # Initiate environment
        self.speedSet =  Entry(master)
        self.speedSet.grid(row=3, column=5)
        self.speedset = Label(master,text="set speed")
        self.speedset.grid(row=3, column=4)

        self.colorset = Button(master, text="setcolor", command=self.setcolor)
        self.colorset.grid(row=4, column=4)

        self.colorentry = Entry(master)
        self.colorentry.grid(row=4, column=5)

        self.title = Label(master, text="my drawing app with turtle")
        self.title.grid(row=0, column=3)

        self.left = Button(master, text="left", command=self.goleft)
        self.left.grid(row=1, column=1)

        self.right = Button(master, text="right", command=self.goright)
        self.right.grid(row=1, column=2)

        self.forward = Button(master, text="forward", command=self.goforward)
        self.forward.grid(row=1, column=3, sticky=E)

        self.backward = Button(master, text="backward", command=self.gobackward)
        self.backward.grid(row=1, column=4)

        self.save = Button(master, text="save", command=self.saveimage)
        self.save.grid(row=6, column=4, sticky=W)

        self.stop = Button(master, text="exit", command=sys.exit)
        self.stop.grid(row=6, column=6)

        self.dissapear = Button(master, text="hide", command=self.hide)
        self.dissapear.grid(row=6, column=1)

        self.show = Button(master, text="show", command=self.appear)
        self.show.grid(row=6, column=2, stick=N + E)

        self.restart = Button(master, text="resetP", command=self.reset)
        self.restart.grid(row=6, column=5, sticky=E)

        self.currentP = Button(text="show current position", command=self.showcurrent)
        self.currentP.grid(row=7, column=5)

        if self.x == 0.124:
            self.t.penup()
            self.t.goto(340.0,00,0)
            self.t.pendown()