本文整理汇总了Python中turtle.exitonclick函数的典型用法代码示例。如果您正苦于以下问题:Python exitonclick函数的具体用法?Python exitonclick怎么用?Python exitonclick使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了exitonclick函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dessiner
def dessiner(l,a,m,azimut=0):
wn = turtle.Screen()
mike = turtle.Turtle()
mike.left(azimut)
coordonneesX=[]
coordonneesY = []
coordonneesA = []
for c in m:
if c=='F':
mike.forward(l)
elif c=='+':
mike.left(a)
elif c=='-':
mike.right(a)
elif c=='[':
coordonneesX.append(mike.xcor())
coordonneesY.append(mike.ycor())
coordonneesA.append(mike.heading())
elif c==']':
mike.penup()
mike.goto(coordonneesX[-1],coordonneesY[-1])
mike.setheading(coordonneesA[-1])
mike.pendown()
coordonneesX.pop(-1)
coordonneesY.pop(-1)
coordonneesA.pop(-1)
else:
break
turtle.exitonclick()
示例2: 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()
示例3: main
def main():
"""
Tous les phase du battleship passe par le main()
et il sert de boucle principal car il est appelé à
tous les 0.5 secondes
"""
if i.phase == "PlaceShip":
i.placeShip()
elif i.phase == "Attack": # Nom fictif
i.attack()
elif i.phase == "win":
print('Vous avez gagné!')
turtle.goto(0,0)
turtle.pencolor('black')
turtle.write('Vous avez gagné!',align="center",font=("Arial",70, "normal"))
i.phase = "exit"
elif i.phase == "lose":
print('Vous avez perdu!')
turtle.goto(0,0)
turtle.pencolor('black')
turtle.write('Vous avez perdu!',align="center",font=("Arial",70, "normal"))
i.phase = "exit"
elif i.phase == "exit":
turtle.exitonclick()
return None
else:
print('out')
turtle.ontimer(main,500)
示例4: main
def main():
board_ac=[10,2,3,4,5,6,7,8,9]
turtle.screensize(300,300)
turtle.hideturtle()
go_to(0,0,0)
board()
#players()
win=0
n_jogada=0
player1=input('Player 1:\t')
player2=input('Player 2:\t')
while win!=1:
n_jogada += 1
if check(board_ac) == True:
if (-1)**n_jogada == -1:
win=1
print(player2, 'Ganhou!')
else:
win=1
print(player1, 'Ganhou!')
else:
player_turn(n_jogada, board_ac)
turtle.exitonclick()
示例5: main
def main():
# Inputs for interpreter and generator
grammar = {'[':_push_state, ']':_pop_state,
'F':_forwards, 'L':_left, 'R':_right,
}
rules = {'T':'F[LT][RT]'}
data = 'T'
generations = 5
# Create a generator
g = Generator(data, rules)
data = g.nth_generation(generations)
# Create and set up interpreter
i = Interpreter(grammar)
i.use_memory = True # Use the interpreter's memory,
# i.e. pass the interpreter as the
# first argument to every callback in the grammar
# Initialise a turtle
t = turtle.Turtle()
t.hideturtle()
t.left(90)
# Load required items into interpreter memory
i.load('turtle', t) # Load in a turtle
i.load('state', []) # Load in an empty list for turtle's state stack
i.execute(data)
turtle.exitonclick()
示例6: demo
def demo():
turtle.forward(100)
turtle.left(120)
turtle.forward(80)
turtle.right(90)
turtle.forward(80)
turtle.exitonclick()
示例7: turtlePrint
def turtlePrint(board, width, height):
turtle.hideturtle()
turtle.speed(0)
turtle.penup()
turtle.goto(-210, -60)
turtle.pendown()
turtle.goto(20*width-210, -60)
turtle.goto(20*width-210, 20*height-60)
turtle.goto(-210, 20*height-60)
turtle.goto(-210, -60)
turtle.penup()
for y in xrange(height):
for x in xrange(width):
turtle.penup()
turtle.goto(20*x-200,20*y-50)
turtle.pendown()
if board[x][y] is 1:
turtle.pencolor("green")
turtle.dot(10)
turtle.pencolor("black")
elif board[x][y] is 2:
turtle.dot(20)
elif board[x][y] is 3:
turtle.pencolor("red")
turtle.dot(10)
turtle.pencolor("black")
elif board[x][y] is 8:
turtle.pencolor("blue")
turtle.dot()
turtle.pencolor("black")
turtle.exitonclick()
示例8: main
def main():
init_turtle()
koch_curve = lsys.lsystem(alphabet, axiom, rules)
tree = koch_curve.apply_rules(int(sys.argv[1]))
koch_curve.perform_actions(tree)
print 'click to exit'
turtle.exitonclick()
示例9: draw_figures
def draw_figures(figures_info):
t = turtle.Turtle()
t.speed('fast')
for f_info in figures_info:
figure_type = f_info['type']
if figure_type == 'square':
draw_square(
turtle_instance=t,
center_x=f_info['center_x'],
center_y=f_info['center_y'],
side_length=f_info['side'],
color=f_info['color']
)
elif figure_type == 'circle':
draw_circle(
turtle_instance=t,
center_x=f_info['center_x'],
center_y=f_info['center_y'],
radius=f_info['radius'],
color=f_info['color']
)
else:
raise ValueError("Unsupported figure")
turtle.exitonclick()
示例10: start
def start():
#E
turtle.backward(50)
turtle.left(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(30)
turtle.penup()
turtle.backward(30)
turtle.pendown()
turtle.left(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(50)
#F
turtle.penup()
turtle.forward(100)
turtle.pendown()
turtle.backward(50)
turtle.right(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
turtle.penup()
turtle.backward(50)
turtle.pendown()
turtle.right(90)
turtle.forward(70)
turtle.exitonclick()
示例11: tscheme_exitonclick
def tscheme_exitonclick():
"""Wait for a click on the turtle window, and then close it."""
global _turtle_screen_on
if _turtle_screen_on:
print("Close or click on turtle window to complete exit")
turtle.exitonclick()
_turtle_screen_on = False
示例12: plot
def plot(a=None,b=None,c=None,scale=10):
f = lambda x: x ** 2
_min = -20
_max = 20
if hasattr(a,'__call__') or type(a) == list:
f = a
elif hasattr(b,'__call__') or type(b) == list:
f = b
_max = a
elif hasattr(c,'__call__') or type(c) == list:
f = c
_max = b
_min = a
if type(f) == list:
_min = 0
ls = f
f = lambda i: ls[max(i,0)]
_max = len(ls)-1
pen = turtle.Turtle()
pen.penup()
pen.goto(_min*scale,f(_min))
pen.pendown()
for x in range(_min,_max+1):
pen.goto(x*scale,f(x))
turtle.exitonclick()
示例13: draw_figures
def draw_figures(figures):
t = turtle.Turtle()
t.speed('slow')
for figure in figures:
figure.draw(t)
turtle.exitonclick()
示例14: main
def main():
turtle.left(90)
turtle.up()
turtle.backward(120)
turtle.down()
drawTree(60)
turtle.exitonclick()
示例15: tscm_exitonclick
def tscm_exitonclick():
"""Wait for a click on the turtle window, and then close it."""
global _turtle_screen_on
if _turtle_screen_on:
turtle.exitonclick()
_turtle_screen_on = False
return UNSPEC