当前位置: 首页>>代码示例>>Python>>正文


Python turtle.mainloop函数代码示例

本文整理汇总了Python中turtle.mainloop函数的典型用法代码示例。如果您正苦于以下问题:Python mainloop函数的具体用法?Python mainloop怎么用?Python mainloop使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了mainloop函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

 def run(self, ticks=1000):
     # run for 1000 ticks
     self.done = False
     #self.screen.ontimer(self.print_fps, 1000)
     self.ticks = ticks
     self.screen.ontimer(self.tick, 33)
     mainloop()
开发者ID:dogonwheels,项目名称:turtlepower,代码行数:7,代码来源:world.py

示例2: drawtree

def drawtree(root):
    def height(root):
        return 1 + max(height(root.left), height(root.right)) if root else -1

    def jumpto(x, y):
        t.penup()
        t.goto(x, y)
        t.pendown()

    def draw(node, x, y, dx):
        if node:
            t.goto(x, y)
            jumpto(x, y - 20)
            t.write(node.val, align='center', font=('Arial', 12, 'normal'))
            draw(node.left, x - dx, y - 60, dx / 2)
            jumpto(x, y - 20)
            draw(node.right, x + dx, y - 60, dx / 2)

    import turtle
    t = turtle.Turtle()
    t.speed(0)
    turtle.delay(0)
    h = height(root)
    jumpto(0, 30 * h)
    draw(root, 0, 30 * h, 40 * h)
    t.hideturtle()
    turtle.mainloop()
开发者ID:dengmare,项目名称:LeetCode,代码行数:27,代码来源:pythonBoilerplate.py

示例3: lab11_2

def lab11_2():
        t1.penup()
       
    	t1.setpos(coord[0])
    	t1.pendown()
    	t1.setpos(coord[0][0],coord[1][1])
    	t1.setpos(coord[1])
    	t1.setpos(coord[1][0],coord[0][1])
    	t1.setpos(coord[0])
    	
        t1.penup()
	t1.setpos(point)
	t1.pendown()
	t1.circle(cr)
	t1.penup()
	t1.setpos(0,0)
    	t1.pendown()
	t2.penup()
	 
    	t2.setpos(p1)	
	t2.pendown()
	t2.setpos(p2)
        maze()    
        addMouse()
        addkeys()
        addexit()
        wn.listen()
        turtle.mainloop()  
开发者ID:chldbtjd,项目名称:p1_201211316,代码行数:28,代码来源:w11Main2.py

示例4: dessine

def dessine(liste):
	"""
	Fonction qui ce charge de dessiner les courbes.
	"""
	# Si la liste reçu n'est pas vide.
	if liste != []:

		# Création de la fenètre turtle.
		t = turtle.Turtle()

		# On cache la tortue.
		t.hideturtle()

		# On met la vitesse max.
		t.speed(0)

		# On configure la taille de la fenètre.
		turtle.setup(width=650,height=650)

		# Création du repère.
		repère(t)

		# On compte le nombre de tour à faire.
		nb_tour = len(liste)

		# Boucle qui permet d'afficher les courbes.
		for n in range(nb_tour):
			e = liste[n]
			f = e[0]
			c = e[1]
			fonction(t,f,c)

		# Mainloop pour que la fenètre reste.
		turtle.mainloop()
开发者ID:alexandreou,项目名称:PyCalc,代码行数:34,代码来源:Add_PyCalc_32_fx.py

示例5: start

def start():
    draw_board()
    #Player vs Bot(first)
    if opponent[0] == "B" and first[0] == "B":
        bot()
    turtle.onscreenclick(play)
    turtle.mainloop()
开发者ID:DCoelhoM,项目名称:Tic-Tac-Toe-Python,代码行数:7,代码来源:Tic-Tac-Toe_by_DCM.py

示例6: polygon_arc

def polygon_arc(t, length, n, angle):
	#t=turtle.Turtle()
    n1 = round((angle/360)*n)
    for i in range(n1):
        t.fd(length)
        t.lt(360/n)
    turtle.mainloop()
开发者ID:xuanguang,项目名称:PythonStudy,代码行数:7,代码来源:4_1_1_square.py

示例7: gamePlay

def gamePlay(): 
    import turtle 
    global wn 
    global t1 
    global coord 
    global radius 
    global cpos 
    global line 
    line=[(-450,-300),(-300,-300)] 
    coord=[(350,-300),(450,-200)] 
    radius=100 
    cpos=(0,-300) 
    wn=turtle.Screen() 
    wn.bgpic("myMaze.gif") 
    t1=turtle.Turtle() 
    setGame() 
    t1.speed(7) 
    t1.penup() 
    t1.goto(-400,300) 
    t1.pendown() 
    t1.pencolor("Red") 
    t1.write("Click or Input Keys") 
    addKeys() 
    addMouse() 
    wn.listen() 
    turtle.mainloop() 
开发者ID:hubls,项目名称:p2_201611092,代码行数:26,代码来源:w11main3.py

示例8: lab11

def lab11():
     t1Init()
     drawLine()
     addKeys()
     addMouse()
     wn.listen()
     turtle.mainloop()
开发者ID:Songic,项目名称:p1_201111232,代码行数:7,代码来源:w11Main.py

示例9: main

def main():
    m = get_user_input()
    draw_grid(m)
    print "Click a square to toggle fill. \nTo switch the fill color press the spacebar."
    WN.onkey(new_fill, "space")
    WN.listen()
    turtle.mainloop()
开发者ID:poemusica,项目名称:turtle-tatami,代码行数:7,代码来源:test_grid.py

示例10: Moving

def Moving(L1):
    for x in range(len(L1)):  # Executes the turtle commands
        if "goto" in L1[x]:  # If goto:
            L1[x] = L1[x].split("(")  # Splits the line by "("
            del L1[x][0]  # Deletes the other end ")"
            L1[x] = L1[x][0][0:-1]  # Stores each value of the list as only the coordinates
            L1[x] = L1[x].split(",")  # Splits the coordinates by the comma between
            for y in range(len(L1[x])):
                L1[x][y] = int(L1[x][y])  # Converts the strings into integers
                turtle.pendown()  # Pen down
                turtle.goto(int(L1[x][0]), int(L1[x][1]))  # Sends the turtle to the x,y coordinates
        if "jumpto" in L1[x]:  # If jumpto:
            L1[x] = L1[x].split("(")  # Splits the line by "("
            del L1[x][0]  # Deletes the other end ")"
            L1[x] = L1[x][0][0:-1]  # Stores each value of the list as only the coordinates
            L1[x] = L1[x].split(",")  # Splits the coordinates by the comma between
            for z in range(len(L1[x])):
                L1[x][z] = int(L1[x][z])  # Converts the strings into integers
                turtle.penup()  # Pen up
                turtle.goto(int(L1[x][0]), int(L1[x][1]))  # Sends the turtle to the x,y coordinates
        if "color" in L1[x]:  # If color
            turtle.color(random.random(), random.random(), random.random())  # Defines random color for turtle
        else:
            continue  # If none of the above criteria is met, do nothing
    turtle.mainloop()  # Keeps turtle on the screen
开发者ID:trsman44,项目名称:Fall-2015,代码行数:25,代码来源:MatthewBowenA7.py

示例11: turtleProgram

def turtleProgram():
    import turtle
    import random
    global length
    turtle.title("CPSC 1301 Assignment 4 MBowen") #Makes the title of the graphic box
    turtle.speed(0) #Makes the turtle go rather fast
    for x in range(1,(numHex+1)): #For loop for creating the hexagons, and filling them up
        turtle.color(random.random(),random.random(),random.random()) #Defines a random color
        turtle.begin_fill()
        turtle.forward(length)
        turtle.left(60)
        turtle.forward(length)
        turtle.left(60)
        turtle.forward(length)
        turtle.left(60)
        turtle.forward(length)
        turtle.left(60)
        turtle.forward(length)
        turtle.left(60)
        turtle.forward(length)
        turtle.left(60)
        turtle.end_fill()
        turtle.left(2160/(numHex))
        length = length - (length/numHex) #Shrinks the hexagons by a small ratio in order to create a more impressive shape
    turtle.penup()   
    turtle.goto(5*length1/2, 0) #Sends turtle to a blank spot
    turtle.color("Black")
    turtle.hideturtle()
    turtle.write("You have drawn %d hexagons in this pattern." %numHex) #Captions the turtle graphic
    turtle.mainloop()
开发者ID:trsman44,项目名称:Fall-2015,代码行数:30,代码来源:MatthewBowenA4.py

示例12: main

def main() :
	wn.listen()
	lab11_3()
	lab11_4()
	lab11_5()
	lab11_6()
	turtle.mainloop()
开发者ID:jhMoon1115,项目名称:p1_201111222,代码行数:7,代码来源:w11Main_2.py

示例13: main

def main():
    #-- creating class object and calling methods 
    game = Game()
    game.print_items()
    game.draw_colors()
    game.draw_cover()
    turtle.mainloop() #-- creates the main loop for turtle screen 
开发者ID:kkhashayar,项目名称:memory-tile-game-gui-version-,代码行数:7,代码来源:mem-puzzle-class.py

示例14: mycircle

def mycircle(t,radius,sides):
    t.fd(radius)
    for i in range(sides):
        t.fd(radius*3/2)
        t.lt(360/sides)
    print(alice)
    turtle.mainloop()
开发者ID:UWPCE-PythonCert,项目名称:IntroPython2016a,代码行数:7,代码来源:mypolygon.py

示例15: play

    def play(self):
        cannon = LaserCannon()
        turtle.ontimer(self.add_alien,2000)
        turtle.listen()

        # Start the event loop.
        turtle.mainloop()
开发者ID:eclass2790,项目名称:Alien_Invaders,代码行数:7,代码来源:Alien+Invader.py


注:本文中的turtle.mainloop函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。