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

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

项目:WWCodeManila-Python    作者:wwcodemanila    | 项目源码 | 文件源码
def main():
    window = turtle.Screen()  # creat a screen
    window.bgcolor("blue")
    lucy = turtle.Turtle()
    lucy.shape("turtle")
    lucy.color("red")
    lucy.width(5)
    lucy.speed(0)

    # Drawing flower
    flower(lucy, 10, 40, 100, 360)

    # Drawing pedicel
    lucy.color("brown")
    lucy.rt(90)
    lucy.fd(200)

    # Drawing leaf
    lucy.rt(270)
    lucy.color("green")
    leaf(lucy, 40, 80, 180)
    lucy.ht()
    window.exitonclick()

# call the main function to start!
项目:miniLogia_Py    作者:ujanlabs    | 项目源码 | 文件源码
def duzyKwadrat(dlBokMalKw):
    numPow = 1
    wnd = turtle.Screen()
    wnd.colormode(255)
    turtle.fillcolor(255, 255, 0)
    turtle.pu()
    turtle.bk(225)
    turtle.lt(90)
    turtle.bk(225 - dlBokMalKw)
    turtle.pd()
    turtle.begin_fill()
    while(numPow <= 4):
        turtle.fd(450 - dlBokMalKw * 2 - 15)
        turtle.rt(90)
        numPow = numPow + 1
    turtle.end_fill()
    turtle.pu()
    turtle.setx(0)
    turtle.sety(0)
    turtle.pd()
    turtle.rt(90)
项目:uband-python-s1-july    作者:guoylyy    | 项目源码 | 文件源码
def main():
    windows = turtle.Screen()#????
    windows.bgcolor('blue')#????
    bran = turtle.Turtle()#????
    bran.shape('turtle')
    bran.color('yellow')
    bran.speed(2)#????
    for i in range(1,5):#????
        bran.forward(100)
        bran.right(45)
        bran.forward(100)
        bran.right(45)
        bran.forward(100)
        bran.right(45)
        bran.forward(100)
        bran.right(45)
项目:uband-python-s1-july    作者:guoylyy    | 项目源码 | 文件源码
def main():
    #??????
    windows=turtle.Screen()
    #????
    windows.bgcolor('pink')
    #???????
    bran=turtle.Turtle()#???T?????
    bran.shape('turtle')
    bran.color('purple')
    #????
    bran.speed(1)

    for i in range(1,20):
        bran.forward(100)
        bran.left(72)
        bran.forward(100)
        bran.right(144)
项目:uband-python-s1-july    作者:guoylyy    | 项目源码 | 文件源码
def main():
  #??????
  windows = turtle.Screen()
  #????
  windows.bgcolor('blue')
  #????????
  bran = turtle.Turtle()
  bran.shape('turtle')
  bran.color('yellow')
  #????
  bran.speed(1)
  #???
  for i in range(1,10):
    bran.forward(100)
    bran.right(90)
    bran.forward(150)
    bran.right(90)
    bran.forward(100)
    bran.right(90)
    bran.forward(150)
    bran.right(90)
  #???
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def main():
    global screen, red, green, blue
    screen = Screen()
    screen.delay(0)
    screen.setworldcoordinates(-1, -0.3, 3, 1.3)

    red = ColorTurtle(0, .5)
    green = ColorTurtle(1, .5)
    blue = ColorTurtle(2, .5)
    setbgcolor()

    writer = Turtle()
    writer.ht()
    writer.pu()
    writer.goto(1,1.15)
    writer.write("DRAG!",align="center",font=("Arial",30,("bold","italic")))
    return "EVENTLOOP"
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def main():
    s = Screen()
    s.bgcolor("black")
    p=Turtle()
    p.speed(0)
    p.hideturtle()
    p.pencolor("red")
    p.pensize(3)

    s.tracer(36,0)

    at = clock()
    mn_eck(p, 36, 19)
    et = clock()
    z1 = et-at

    sleep(1)

    at = clock()
    while any([t.undobufferentries() for t in s.turtles()]):
        for t in s.turtles():
            t.undo()
    et = clock()
    return "runtime: %.3f sec" % (z1+et-at)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def main():
    global screen, red, green, blue
    screen = Screen()
    screen.delay(0)
    screen.setworldcoordinates(-1, -0.3, 3, 1.3)

    red = ColorTurtle(0, .5)
    green = ColorTurtle(1, .5)
    blue = ColorTurtle(2, .5)
    setbgcolor()

    writer = Turtle()
    writer.ht()
    writer.pu()
    writer.goto(1,1.15)
    writer.write("DRAG!",align="center",font=("Arial",30,("bold","italic")))
    return "EVENTLOOP"
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def main():
    s = Screen()
    s.bgcolor("black")
    p=Turtle()
    p.speed(0)
    p.hideturtle()
    p.pencolor("red")
    p.pensize(3)

    s.tracer(36,0)

    at = clock()
    mn_eck(p, 36, 19)
    et = clock()
    z1 = et-at

    sleep(1)

    at = clock()
    while any([t.undobufferentries() for t in s.turtles()]):
        for t in s.turtles():
            t.undo()
    et = clock()
    return "Laufzeit: %.3f sec" % (z1+et-at)
项目:PythonMaterial    作者:udhayprakash    | 项目源码 | 文件源码
def draw_square():
    window = turtle.Screen()
    window.bgcolor("red")

    brad = turtle.Turtle()
    brad.shape("turtle")
    brad.color("yellow")
    brad.speed(5)
    counter = 0
    while counter < 36:
        brad.forward(100)
        brad.right(90)
        brad.forward(100)
        brad.right(90)
        brad.forward(100)
        brad.right(90)
        brad.forward(100)
        brad.right(100)
        counter += 1

    window.exitonclick()
项目:Leetcode    作者:staticor    | 项目源码 | 文件源码
def main():
    tList = []
    head = 0
    numTurtles = 10
    wn = turtle.Screen()
    wn.setup(500,500)
    for i in range(numTurtles):
        nt = turtle.Turtle()   # Make a new turtle, initialize values
        nt.setheading(head)
        nt.pensize(2)
        nt.color(random.randrange(256),random.randrange(256),random.randrange(256))
        nt.speed(10)
        wn.tracer(30,0)
        tList.append(nt)       # Add the new turtle to the list
        head = head + 360/numTurtles

    for i in range(100):
        moveTurtles(tList,15,i)

    w = tList[0]
    w.up()
    w.goto(0,40)
    w.write("How to Think Like a ",True,"center","40pt Bold")
    w.goto(0,-35)
    w.write("Computer Scientist",True,"center","40pt Bold")
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def main():
    global screen, red, green, blue
    screen = Screen()
    screen.delay(0)
    screen.setworldcoordinates(-1, -0.3, 3, 1.3)

    red = ColorTurtle(0, .5)
    green = ColorTurtle(1, .5)
    blue = ColorTurtle(2, .5)
    setbgcolor()

    writer = Turtle()
    writer.ht()
    writer.pu()
    writer.goto(1,1.15)
    writer.write("DRAG!",align="center",font=("Arial",30,("bold","italic")))
    return "EVENTLOOP"
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def main():
    s = Screen()
    s.bgcolor("black")
    p=Turtle()
    p.speed(0)
    p.hideturtle()
    p.pencolor("red")
    p.pensize(3)

    s.tracer(36,0)

    at = clock()
    mn_eck(p, 36, 19)
    et = clock()
    z1 = et-at

    sleep(1)

    at = clock()
    while any([t.undobufferentries() for t in s.turtles()]):
        for t in s.turtles():
            t.undo()
    et = clock()
    return "runtime: %.3f sec" % (z1+et-at)
项目:python-Uband    作者:sy-yunyi    | 项目源码 | 文件源码
def main():
  #??????
  windows = turtle.Screen()
  # windows.onclick(get)
  #????
  windows.bgcolor('blue')
  #????????
  bran.shape('turtle')
  bran.color('black')
  bran.onclick(turn)
  #??????
  while True:
    # bran.stamp()
    bran.backward(60)

    # bran.undo()
    bran.right(90)
  # hitTurtle(100,0,1,60,50,0,"yellow")
项目:python-Uband    作者:sy-yunyi    | 项目源码 | 文件源码
def main():
  #??????
  windows = turtle.Screen()
  #????
  windows.bgcolor('blue')
  #????????
  bran = turtle.Turtle()
  bran.shape('turtle')
  bran.color('yellow')
  #????
  bran.speed(1)
  #???
  for i in range(1,10):
    bran.forward(100)
    bran.right(90)
    bran.forward(150)
    bran.right(90)
    bran.forward(100)
    bran.right(90)
    bran.forward(150)
    bran.right(90)
  #???
项目:python-Uband    作者:sy-yunyi    | 项目源码 | 文件源码
def main():
    # windows=turtle.Screen()
    # windows.bgcolor('blue')
    bran=turtle.Turtle()
    bran.shape('classic')
    bran.color('black')
    bran.speed(2)
    while True:
        # bran.forward(10)
        bran.down()
        bran.right(60)
        bran.circle(80)
        # bran.forward(10)
        # bran2.left(30)
        # bran2.goto(0,0)
        # bran2.forward(10)
项目:python-Uband    作者:sy-yunyi    | 项目源码 | 文件源码
def runTurtle():
    windows=turtle.Screen()
    windows.bgcolor("blue")
    tu=[]
    i=0
    hit(i)
    for i in range(10):
        bran=turtle.Turtle()
        bran.hideturtle()
        bran.color("yellow")
        bran.shape("turtle")
        bran.shapesize(1,1)
        bran.onclick(turn)
        bran.up()
        bran.goto(i*30,0)
        tu.append(bran)
    while 1:
        n=(int)(random.uniform(0, 10))
        for i in range(10):
            tu[i].hideturtle()
        tu[n].showturtle()
        time.sleep(1)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def main():
    global screen, red, green, blue
    screen = Screen()
    screen.delay(0)
    screen.setworldcoordinates(-1, -0.3, 3, 1.3)

    red = ColorTurtle(0, .5)
    green = ColorTurtle(1, .5)
    blue = ColorTurtle(2, .5)
    setbgcolor()

    writer = Turtle()
    writer.ht()
    writer.pu()
    writer.goto(1,1.15)
    writer.write("DRAG!",align="center",font=("Arial",30,("bold","italic")))
    return "EVENTLOOP"
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def main():
    s = Screen()
    s.bgcolor("black")
    p=Turtle()
    p.speed(0)
    p.hideturtle()
    p.pencolor("red")
    p.pensize(3)

    s.tracer(36,0)

    at = clock()
    mn_eck(p, 36, 19)
    et = clock()
    z1 = et-at

    sleep(1)

    at = clock()
    while any([t.undobufferentries() for t in s.turtles()]):
        for t in s.turtles():
            t.undo()
    et = clock()
    return "runtime: %.3f sec" % (z1+et-at)
项目:graph    作者:Gretter74    | 项目源码 | 文件源码
def myInitialize():
    #wn = turtle.Screen()
    alex = turtle.Turtle()
    alex.forward(150)
    alex.right(200)
    alex.write("Initialization done.")
    print ("Initialization done.")
项目:Python-first-Practice    作者:MurphyWan    | 项目源码 | 文件源码
def Turtle_Mini_Project_KC():
    window = turtle.Screen()
    window.bgcolor("white")
    brad = turtle.Turtle()
    brad.shape("turtle")
    brad.color("blue")
    brad.speed(1)

    draw_K(brad)
    draw_C(brad)

    window.exitonclick()
项目:uband-python-s1-july    作者:guoylyy    | 项目源码 | 文件源码
def main():
  #??????
  windows = turtle.Screen()
  #????
  windows.bgcolor('blue')
  #????????
  bran = turtle.Turtle()
  bran.shape('turtle')
  bran.color('yellow')
  #??????
  for i in range(1,3):
    bran.setposition(300,300)
    bran.setheading(90)
    bran.setposition(300,0)
    bran.setheading(90)
    bran.setposition(0,0)
    bran.setheading(90)

    bran.dot(60,'red')

  bran.color('black')
  bran.stamp()
  bran.forward(-300)
  bran.right(90)
  bran.forward(300)
  bran.left(90)
  bran.forward(300)

  bran.clearstamps()

  for i in range(5):
    bran.undo()
项目:uband-python-s1-july    作者:guoylyy    | 项目源码 | 文件源码
def main():
  #??????
  windows = turtle.Screen()
  #????
  windows.bgcolor('blue')
  #????????
  bran = turtle.Turtle()
  bran.shape('turtle')
  bran.color('yellow')
  #??????
项目:Beginners-Python-Examples    作者:AsciiKay    | 项目源码 | 文件源码
def square():
    win = turtle.Screen()
    win.bgcolor("white")
    jack = turtle.Turtle()
    for x in range(1,5):
              jack.forward(100)
              jack.right(90)
    win.exitonclick()
项目:miniLogia_Py    作者:ujanlabs    | 项目源码 | 文件源码
def main():
    wnd = turtle.Screen()
    wnd.colormode(255)
    kwiatek()
项目:miniLogia_Py    作者:ujanlabs    | 项目源码 | 文件源码
def main():
    wnd = turtle.Screen()
    wnd.colormode(255)
    wiatrak(6)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def main():
    mainscreen = turtle.Screen()
    mainscreen.mode("standard")
    mainscreen.setup(SCREENWIDTH, SCREENHEIGHT)
    nim = Nim(mainscreen)
    return "EVENTLOOP!"
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def makeGraphFrame(self, root):
        turtle._Screen._root = root
        self.canvwidth = 1000
        self.canvheight = 800
        turtle._Screen._canvas = self._canvas = canvas = turtle.ScrolledCanvas(
                root, 800, 600, self.canvwidth, self.canvheight)
        canvas.adjustScrolls()
        canvas._rootwindow.bind('<Configure>', self.onResize)
        canvas._canvas['borderwidth'] = 0

        self.screen = _s_ = turtle.Screen()
        turtle.TurtleScreen.__init__(_s_, _s_._canvas)
        self.scanvas = _s_._canvas
        turtle.RawTurtle.screens = [_s_]
        return canvas
项目:PythonMaterial    作者:udhayprakash    | 项目源码 | 文件源码
def main():
    my_turtle = turtle.Turtle()
    my_win = turtle.Screen()
    my_points = [[-100, -50], [0, 100], [100, -50]]
    sierpinski(my_points, 3, my_turtle)
    my_win.exitonclick()
项目:linedraw    作者:LingDong-    | 项目源码 | 文件源码
def visualize(lines):
    import turtle
    wn = turtle.Screen()
    t = turtle.Turtle()
    t.speed(0)
    t.pencolor('red')
    t.pd()
    for i in range(0,len(lines)):
        for p in lines[i]:
            t.goto(p[0]*640/1024-320,-(p[1]*640/1024-320))
            t.pencolor('black')
        t.pencolor('red')
    turtle.mainloop()
项目:nustack    作者:BookOwl    | 项目源码 | 文件源码
def start():
    if not start.started:
        turtle.Screen().title("Nustack Turtle Graphics")
        start.started = True
项目:nustack    作者:BookOwl    | 项目源码 | 文件源码
def Screen(env) -> "( -- screen)":
    'Returns the Screen used by the turtles.'
    start()
    "Returns the Screen used by turtles"
    s = Token("lit_screen", turtle.Screen())
    env.stack.push(s)
项目:Raspberry-Pi-Making-Amazing-Projects-Right-from-Scratch-    作者:PacktPublishing    | 项目源码 | 文件源码
def main():
    myTurtle = turtle.Turtle()
    myWin = turtle.Screen()
    myTurtle.penup()
    myTurtle.backward(250)
    myTurtle.pendown()
    koch ( myTurtle, 4, 500 )
    myWin.exitonclick()
项目:Raspberry-Pi-Making-Amazing-Projects-Right-from-Scratch-    作者:PacktPublishing    | 项目源码 | 文件源码
def main():
   myTurtle = turtle.Turtle()
   myWin = turtle.Screen()
   myPoints = [[-100,-50],[0,100],[100,-50]]
   sierpinski(myPoints,3,myTurtle)
   myWin.exitonclick()
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def main():
    mainscreen = turtle.Screen()
    mainscreen.mode("standard")
    mainscreen.setup(SCREENWIDTH, SCREENHEIGHT)
    nim = Nim(mainscreen)
    return "EVENTLOOP"
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def makeGraphFrame(self, root):
        turtle._Screen._root = root
        self.canvwidth = 1000
        self.canvheight = 800
        turtle._Screen._canvas = self._canvas = canvas = turtle.ScrolledCanvas(
                root, 800, 600, self.canvwidth, self.canvheight)
        canvas.adjustScrolls()
        canvas._rootwindow.bind('<Configure>', self.onResize)
        canvas._canvas['borderwidth'] = 0

        self.screen = _s_ = turtle.Screen()
        turtle.TurtleScreen.__init__(_s_, _s_._canvas)
        self.scanvas = _s_._canvas
        turtle.RawTurtle.screens = [_s_]
        return canvas
项目:python-Uband    作者:sy-yunyi    | 项目源码 | 文件源码
def main():
  #??????
  windows = turtle.Screen()
  #????
  windows.bgcolor('blue')
  #????????
  bran = turtle.Turtle()
  bran.shape('turtle')
  bran.color('yellow')
  #????
  bran.speed(5)
  i=0;
  bran.write(i)
  i=i+1
  bran.circle(120, 720)
  bran.write(i)

  # #???
  # for i in range(1,10):
  #   bran.forward(100)
  #   bran.right(90)
  #   bran.forward(150)
  #   bran.right(90)
  #   bran.forward(100)
  #   bran.right(90)
  #   bran.forward(150)
  #   bran.right(90)
  # #???
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def main():
    mainscreen = turtle.Screen()
    mainscreen.mode("standard")
    mainscreen.setup(SCREENWIDTH, SCREENHEIGHT)
    nim = Nim(mainscreen)
    return "EVENTLOOP"
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def makeGraphFrame(self, root):
        turtle._Screen._root = root
        self.canvwidth = 1000
        self.canvheight = 800
        turtle._Screen._canvas = self._canvas = canvas = turtle.ScrolledCanvas(
                root, 800, 600, self.canvwidth, self.canvheight)
        canvas.adjustScrolls()
        canvas._rootwindow.bind('<Configure>', self.onResize)
        canvas._canvas['borderwidth'] = 0

        self.screen = _s_ = turtle.Screen()
        turtle.TurtleScreen.__init__(_s_, _s_._canvas)
        self.scanvas = _s_._canvas
        turtle.RawTurtle.screens = [_s_]
        return canvas
项目:particle_filter    作者:rcorona    | 项目源码 | 文件源码
def __init__(self):
        #Creates display for visualization. 
        self.window = turtle.Screen()
        turtle.setworldcoordinates(-5, -5, 5, 5)
        turtle.speed(0)

        #Initializes ROS and subscribes to particle filter. 
        rospy.init_node('particle_visualizer', anonymous=True)
        rospy.Subscriber('particle_filter', Particle_vector, self.update)

        #Initializes list of particles. 
        self.particles = []
项目:miniLogia_Py    作者:ujanlabs    | 项目源码 | 文件源码
def kwScRog(dlBokKw):
    wnd = turtle.Screen()
    wnd.colormode(255)
    turtle.fillcolor(102, 51, 0)
    numPow = 1
    bokMalKw = math.floor((dlBokKw - (dlBokKw / 5) * 2))
    scBok = math.sqrt(((dlBokKw / 5) ** 2) * 2)
    turtle.begin_fill()
    while(numPow <= 4):
        turtle.fd(bokMalKw)
        turtle.lt(45)
        turtle.fd(scBok)
        turtle.lt(45)
        numPow = numPow + 1
    turtle.end_fill()
项目:python0-reloaded    作者:YAtOff    | 项目源码 | 文件源码
def play(move_player):
    window = turtle.Screen()
    window.bgcolor('black')
    window.tracer(0)

    player = turtle.Turtle()
    player.penup()
    player.setposition(-PLAYGROUND_SIDE, 0)
    player.speed(0)
    player.color('white')

    play_game = True

    def quit_game():
        play_game = False

    window.listen()
    window.onkey(quit_game, 'q')

    drow_border()
    place_enemies()

    while play_game:
        start_time = time.clock()

        old_x, old_y = player.xcor(), player.ycor()

        move_player(player)

        x, y = player.xcor(), player.ycor()
        if 1 < abs(old_x - x) or 1 < abs(old_y - y):
            play_game = False
        elif not can_move(x, y):
            play_game = False
        elif player.xcor() == PLAYGROUND_SIDE:
            play_game = False

        window.update()
        elapsed = time.clock() - start_time
        if elapsed < FRAME_PERIOD:
            time.sleep(FRAME_PERIOD - elapsed)

    window.bye()