本文整理汇总了Python中turtle.getscreen函数的典型用法代码示例。如果您正苦于以下问题:Python getscreen函数的具体用法?Python getscreen怎么用?Python getscreen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getscreen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: drawWith
def drawWith(self, turtle):
self.height = turtle.getscreen().window_height()
self.width = turtle.getscreen().window_width()
for drawableObject in self.drawableObjects:
drawableObject.draw(turtle)
turtle.getscreen().update()
示例2: funcion
def funcion(numero, diametro):
t=turtle.Pen()
angulo=360/numero
for x in range (1,numero+1):
t.forward(diametro)
t.left(angulo)
turtle.getscreen()._root.mainloop()
示例3: graficarFigura
def graficarFigura():
t=turtle.Pen()
angulo = (180/lados)+180
t.pencolor("red")
for x in range(0,lados):
t.forward(250)
t.right(angulo)
turtle.getscreen()._root.mainloop()
示例4: draw_square
def draw_square(x,y):
turtle.penup()
turtle.goto(x,y)
turtle.pendown()
turtle.goto(x+50,y)
turtle.goto(x+50,y+50)
turtle.goto(x,y+50)
turtle.goto(x,y)
turtle.getscreen().onkeypress(draw_square, "s")
turtle.getscreen().listen()
示例5: drawcurve
def drawcurve(points):
myTurtle = turtle.Turtle(shape="turtle")
turtle.screensize(500,500)
turtle.setworldcoordinates(400,400,500,500)
myTurtle.penup()
y = points[0]
myTurtle.setposition(y[0], y[1])
myTurtle.pendown()
for x in points:
myTurtle.setposition(x[0], x[1])
turtle.getscreen()._root.mainloop()
示例6: main
def main():
turtle.colormode(1.)
turtle.speed(0)
for depth in range(9):
if 7 > depth > 4: # for faster rendering.
turtle.getscreen().tracer(0)
global count
count = 0
hilbert(0.0, 0.0, 1.0, 0.0, 0.0, 1.0, depth)
turtle.getscreen().tracer(1)
#time.sleep(2)
turtle.Screen().exitonclick()
示例7: setup
def setup(col, x, y, w, s, shape):
turtle.up()
turtle.goto(x,y)
turtle.width(w)
turtle.turtlesize(s)
turtle.color(col)
turtle.shape(shape)
turtle.bgpic("assets/dancing-banana.gif")
turtle.down()
wn.listen()
turtle.getscreen()._root.bind_all('<Key>', key_pressed)
turtle.getscreen()._root.mainloop()
示例8: initialize_plot
def initialize_plot(self, positions):
self.positions = positions
self.minX = minX = min(x for x,y in positions.values())
maxX = max(x for x,y in positions.values())
minY = min(y for x,y in positions.values())
self.maxY = maxY = max(y for x,y in positions.values())
ts = turtle.getscreen()
if ts.window_width > ts.window_height:
max_size = ts.window_height()
else:
max_size = ts.window_width()
self.width, self.height = max_size, max_size
turtle.setworldcoordinates(minX-5,minY-5,maxX+5,maxY+5)
turtle.setup(width=self.width, height=self.height)
turtle.speed("fastest") # important! turtle is intolerably slow otherwise
turtle.tracer(False) # This too: rendering the 'turtle' wastes time
turtle.hideturtle()
turtle.penup()
self.colors = ["#d9684c","#3d658e","#b5c810","#ffb160","#bd42b3","#0eab6c","#1228da","#60f2b7" ]
for color in self.colors:
s = turtle.Shape("compound")
poly1 = ((0,0),(self.cell_size,0),(self.cell_size,-self.cell_size),(0,-self.cell_size))
s.addcomponent(poly1, color, "#000000")
turtle.register_shape(color, s)
s = turtle.Shape("compound")
poly1 = ((0,0),(self.cell_size,0),(self.cell_size,-self.cell_size),(0,-self.cell_size))
s.addcomponent(poly1, "#000000", "#000000")
turtle.register_shape("uncolored", s)
示例9: drawcicle
def drawcicle(noOfInterface,val):
tlist = list()
screen = turtle.getscreen()
screen.tracer(0)
for i in range(noOfInterface):
tlist.append(turtle.Turtle())
tlist[i].up()
tlist[i].back(val)
tlist[i].left(90)
tlist[i].forward(200-(10+90*i))
tlist[i].begin_fill()
tlist[i].down()
tlist[i].circle(15)
tlist[i].end_fill()
tlist[i].hideturtle()
for i in range(noOfInterface):
turt = turtle.Turtle()
turt.up()
turt.back(val-300)
turt.left(90)
turt.forward(200-(10+90*i))
turt.begin_fill()
turt.down()
turt.circle(15)
turt.end_fill()
turt.hideturtle()
screen.update()
示例10: main
def main():
file_name = "go"
file_name = raw_input( 'Enter a file name or exit to quit program: ')
while (file_name != "exit" and file_name != "Exit" and file_name != "quit" and file_name != "Quit"):
f = open( file_name, 'r' )
first_line = f.readline()
first_line = first_line.split()
distance = float( first_line[0] )
angle = float( first_line[1] )
stack = []
wn = tur.Screen()
for line in f:
wn.clear()
tur.penup()
tur.seth(90)
tur.setx(0)
tur.sety(-200)
tur.pendown()
interprit_line(tur, line, angle, distance, stack)
ts = tur.getscreen()
ts.getcanvas().postscript(file=file_name +".eps")
wn.exitonclick()
file_name = raw_input( 'Enter a file name or exit to quit program: ')
示例11: a
def a(fill=False):
'''draws a capital A.'''
turtle.setheading(0)
if fill: bf()
fd(10)
turtle.goto(turtle.xcor() + 5, turtle.ycor() + 40)
fd(10)
turtle.goto(turtle.xcor() + 5, turtle.ycor() - 40)
fd(10)
turtle.goto(turtle.xcor() - 15, turtle.ycor() + 110)
turtle.setx(turtle.xcor() - 10)
turtle.goto(turtle.xcor() - 15, turtle.ycor() - 110)
if fill: ef()
pu()
turtle.goto(turtle.xcor() + 17, turtle.ycor() + 50)
pd()
if fill:
cfc = fc()
fc(turtle.getscreen().bgcolor())
bf()
fd(6)
turtle.goto(turtle.xcor() - 3, turtle.ycor() + 40)
turtle.goto(turtle.xcor() - 3, turtle.ycor() - 40)
if fill:
ef()
fc(cfc)
pu()
turtle.goto(turtle.xcor() + 33, turtle.ycor() - 50)
pd()
示例12: draw
def draw(x,y,count,isGrant,val,acceptCount):
List_Of_Turtles = list()
p = list()
screen = turtle.getscreen()
screen.setup( width = 2000, height = 2000, startx = None, starty = None)
for i in range(count):
screen.tracer(10)
List_Of_Turtles.append(turtle.Turtle())
#print "here",i,acceptCount,count
List_Of_Turtles[i].color("red")
if i >= acceptCount-1 and acceptCount!= 0:
List_Of_Turtles[i].shape("square")
List_Of_Turtles[i].color("green")
List_Of_Turtles[i].speed(1)
List_Of_Turtles[i].width(4)
angle = math.atan((y[i]-x[i])/300.0)
p.append(math.sqrt(90000+(x[i]-y[i])*(x[i]-y[i])))
if val == 200:
Position_Set(List_Of_Turtles[i],val-275,200-x[i])
else:
Position_Set(List_Of_Turtles[i],val,200-x[i])
if isGrant == 1:
List_Of_Turtles[i].right(180-math.degrees(angle)+90)
else:
List_Of_Turtles[i].right(math.degrees(angle)+90)
screen.update()
for i in xrange(100):
j=0
for t in List_Of_Turtles:
t.down()
if (i*(i+1))/2 < p[j]:
t.forward(i)
j=j+1
screen.update()
示例13: viewer
def viewer(dna):
'''Display ORFs and GC content for dna.'''
dna = dna.upper() # make everything upper case, just in case
t = turtle.Turtle()
turtle.setup(1440, 240) # make a long, thin window
turtle.screensize(len(dna) * 6, 200) # make the canvas big enough to hold the sequence
# scale coordinate system so one character fits at each point
setworldcoordinates(turtle.getscreen(), 0, 0, len(dna), 6)
turtle.hideturtle()
t.speed(0)
t.tracer(100)
t.hideturtle()
# Draw the sequence across the bottom of the window.
t.up()
for i in range(len(dna)):
t.goto(i, 0)
t.write(dna[i],font=("Helvetica",8,"normal"))
# Draw bars for ORFs in forward reading frames 0, 1, 2.
# Draw the bar for reading frame i at y = i + 1.
t.width(5) # width of the pen for each bar
for i in range(3):
orf(dna, i, t)
t.width(1) # reset the pen width
gcFreq(dna, 20, t) # plot GC content over windows of size 20
turtle.exitonclick()
示例14: saveImg
def saveImg():
print("Done.")
save = input("Would you like to save this tree? Y/N \n")
if save.upper() == "Y":
t.hideturtle()
name = input("What would you like to name it? \n")
nameSav = name + ".svg"
ts = turtle.getscreen().getcanvas()
canvasvg.saveall(nameSav, ts)
elif save.upper() == "N":
def runChk():
runAgain = input("Would you like to run again? Y/N (N will exit)")
if runAgain.upper() == "Y":
print("Running")
main()
elif runAgain.upper() == "N":
print("Exiting...")
exit()
else:
print("Invalid response.")
runChk()
runChk()
else:
print("Invalid response.")
saveImg()
示例15: draw
def draw(x,y,count,isGrant,val):
tlist = list()
p = list()
screen = turtle.getscreen()
screen.setup( width = 2000, height = 2000, startx = None, starty = None)
for i in range(count):
screen.tracer(10)
tlist.append(turtle.Turtle())
tlist[i].color("red")
tlist[i].speed(1)
tlist[i].width(4)
angle = math.atan((y[i]-x[i])/300.0)
p.append(math.sqrt(90000+(x[i]-y[i])*(x[i]-y[i])))
tlist[i].up()
if val == 200:
tlist[i].back(val-275)
else:
tlist[i].back(val)
tlist[i].left(90)
tlist[i].forward(200-x[i])
if isGrant == 1:
tlist[i].right(180-math.degrees(angle)+90)
else:
tlist[i].right(math.degrees(angle)+90)
screen.update()
for i in xrange(100):
j=0
for t in tlist:
t.down()
if (i*(i+1))/2 < p[j]:
t.forward(i)
j=j+1
screen.update()