是否可以从同一代码同时执行2个或更多的Turtle Windows(Tk)?

时间:2019-04-16 03:04:14

标签: python-3.x turtle-graphics

由于在1个tk窗口中同时用两只海龟绘制一张图不能很好地工作,我想知道是否更容易同时在不同的窗口中绘制图的每个部分。

Ex:

from turtle import Screen, Turtle
import random

screen = Screen()
t = Turtle(visible=False)
t.speed('fastest')  # because I have no patience

def got(x,y,d) :
    t.penup()
    t.goto(x,y)
    t.pendown()
    t.seth(d)


def tuneis(ragn):
    d=0
    for i in range(ragn):

        got(0,0,d)  
        d = d + 10
        t.penup()

        t.forward(400)
        t.pendown()
        t.forward(500)

tuneis(36)
real = []

def realidade(ragn) :
    d=5
    for i in range(ragn):
        b = random.randint(10,50)
        t.pensize(b)
        t.color('green')
        got(0,0,d)  
        real.append(b)
        d = d + 10
        t.penup()

        t.forward(450)
        t.pendown()
        t.forward(500)

realidade(36)

def filo(x,y):
        cont = x        
        t.color('green')
        for i in real:

            t.pensize(0)
            #b=random.randint(10,50)

            got(cont,y,0)
            cont = cont + 10

            t.setheading(270)
            t.forward(i)
        y= y + 20
        cont = cont - (len(real)*10 / 2)
        d=0
        for i in real :
            got(cont,y,d)
            t.forward(i)
            d=d+5


filo(-200,300)

是否可以在一个窗口中同时绘制“ tuneis”和“ realidade”,并在另一个窗口中绘制“ filo”?

0 个答案:

没有答案