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!
python类Screen()的实例源码
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)
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)
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)
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)
#???
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"
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)
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"
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)
03_circular_patterns_with_sqaures.py 文件源码
项目:PythonMaterial
作者: udhayprakash
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
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()
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")
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"
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)
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")
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)
#???
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)
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)
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"
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)
def myInitialize():
#wn = turtle.Screen()
alex = turtle.Turtle()
alex.forward(150)
alex.right(200)
alex.write("Initialization done.")
print ("Initialization done.")
Turtle_Mini_Project_KC.py 文件源码
项目:Python-first-Practice
作者: MurphyWan
项目源码
文件源码
阅读 24
收藏 0
点赞 0
评论 0
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()
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()
def main():
#??????
windows = turtle.Screen()
#????
windows.bgcolor('blue')
#????????
bran = turtle.Turtle()
bran.shape('turtle')
bran.color('yellow')
#??????
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()
def main():
wnd = turtle.Screen()
wnd.colormode(255)
kwiatek()
def main():
wnd = turtle.Screen()
wnd.colormode(255)
wiatrak(6)
def main():
mainscreen = turtle.Screen()
mainscreen.mode("standard")
mainscreen.setup(SCREENWIDTH, SCREENHEIGHT)
nim = Nim(mainscreen)
return "EVENTLOOP!"
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
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()
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()