• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python turtle.title函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: main

def main():
    #设置窗口信息
    turtle.title('数据驱动的动态路径绘制')
    turtle.setup(800, 600, 0, 0)
    #设置画笔
    pen = turtle.Turtle()
    pen.color("red")
    pen.width(5)
    pen.shape("turtle")
    pen.speed(5)
    #读取文件
    result=[]
    file = open("data.txt","r")
    for line in file:
        result.append(list(map(float, line.split(','))))
    print(result)
    #动态绘制
    for i in range(len(result)):
        pen.color((result[i][3],result[i][4],result[i][5]))
        pen.forward(result[i][0])
        if result[i][1]:
            pen.rt(result[i][2])
        else:
            pen.lt(result[i][2])
    pen.goto(0,0)
开发者ID:guanmfei,项目名称:learngit,代码行数:25,代码来源:file_turtle.py


示例2: koch

def koch(niveau=3, iter=0, taille=100, delta=0):
    """
    Tracé du flocon de Koch de niveau 'niveau', de taille 'taille'
    (px).

    Cette fonction récursive permet d'initialiser le flocon (iter=0,
    par défaut), de tracer les branches fractales (0<iter<=niveau) ou
    bien juste de tracer un segment (iter>niveau).
    """

    if iter == 0:                         # Dessine le triangle de niveau 0
        T.title("Flocon de Koch - niveau {}".format(niveau))
        koch(iter=1, niveau=niveau, taille=taille, delta=delta)
        T.right(120)
        koch(iter=1, niveau=niveau, taille=taille, delta=delta)
        T.right(120)
        koch(iter=1, niveau=niveau, taille=taille, delta=delta)
    elif iter <= niveau:                  # Trace une section _/\_ du flocon
        koch(iter=iter + 1, niveau=niveau, taille=taille, delta=delta)
        T.left(60 + delta)
        koch(iter=iter + 1, niveau=niveau, taille=taille, delta=delta)
        T.right(120 + 2 * delta)
        koch(iter=iter + 1, niveau=niveau, taille=taille, delta=delta)
        T.left(60 + delta)
        koch(iter=iter + 1, niveau=niveau, taille=taille, delta=delta)
    else:                               # Trace le segment de dernier niveau
        T.forward(taille / 3 ** (niveau + 1))
开发者ID:ycopin,项目名称:Informatique-Python,代码行数:27,代码来源:koch.py


示例3: main

def main():
  ap = ArgumentParser()
  ap.add_argument('--speed', type=int, default=10,
                  help='Number 1-10 for drawing speed, or 0 for no added delay')
  ap.add_argument('program')
  args = ap.parse_args()

  for kind, number, path in parse_images(args.program):
    title = '%s #%d, path length %d' % (kind, number, path.shape[0])
    print(title)
    if not path.size:
      continue
    pen_up = (path==0).all(axis=1)
    # convert from path (0 to 65536) to turtle coords (0 to 655.36)
    path = path / 100.
    turtle.title(title)
    turtle.speed(args.speed)
    turtle.setworldcoordinates(0, 655.36, 655.36, 0)
    turtle.pen(shown=False, pendown=False, pensize=10)
    for i,pos in enumerate(path):
      if pen_up[i]:
        turtle.penup()
      else:
        turtle.setpos(pos)
        turtle.pendown()
        turtle.dot(size=10)
    _input('Press enter to continue')
    turtle.clear()
  turtle.bye()
开发者ID:perimosocordiae,项目名称:pyhrm,代码行数:29,代码来源:extract_images.py


示例4: __init__

    def __init__(self):
        turtle.title('Phogo - CRM UAM')
        turtle.mode('logo')
        turtle.penup()

        #turtle.setx(turtle.screensize()[0] // 8)
        turtle.screensize(4000, 4000)
开发者ID:CRM-UAM,项目名称:Phogo,代码行数:7,代码来源:tortoise_turtle.py


示例5: display

    def display( self, text ):
        """Display the finished graphic until the window is closed.

        Might be better to display until key click or mouse click.
        """
        turtle.title( text )
        turtle.ht()
开发者ID:slott56,项目名称:HamCalc-2.1,代码行数:7,代码来源:gwgraphics.py


示例6: __init__

    def __init__(self, model):
        """Initialize the view at the starting of the application."""
        self.model = model

        self.cellWidth = self.CELL_WIDTH
        self.model = model
        self.gridSize = model.GRID_SIZE
        self.player = self.model.player1
        self.screen = turtle.Screen()
        self.gridWidth = self.CELL_WIDTH * self.gridSize
        self.playerGrid = self.player.getGrid(self.player.PLAYER_GRID)
        self.enemyGrid = self.player.getGrid(self.player.OPPONENT_GRID)
        self.iconsToDraw = []

        turtle.title('BATTLESHIP : {} vs {}'.format(
            self.model.player1.playerName, self.model.player2.playerName))
        self.__setScreen()
        self.__setColor()
        turtle.tracer(0, 0)

        gridWidth = self.gridWidth
        gridAnchorPoints = []
        gridAnchorPoints.append((
            -self.width/2 + self.GRID_MARGINLEFT,
            self.height/2 - self.GRID_MARGINTOP - gridWidth))
        gridAnchorPoints.append((
            self.width/2 - gridWidth - self.GRID_MARGINRIGHT,
            self.height/2 - self.GRID_MARGINTOP - gridWidth ))

        self.__drawGrid(gridAnchorPoints[0], gridWidth)
        self.__drawGrid(gridAnchorPoints[1], gridWidth)

        self.gridAnchorPoints = gridAnchorPoints
开发者ID:raphaelgodro,项目名称:BattleShip-Human-AI-Network,代码行数:33,代码来源:view_window.py


示例7: main

def main():
    #用户输入一个文件名
    filename = input("enter a filename: ").strip()
    infile = open(filename, 'r')

    #建立用于计算词频的空字典
    wordCounts = {}
    for line in infile:
        processLine(line.lower(), wordCounts)

    #从字典中获取数据对
    pairs = list(wordCounts.items())

    #列表中的数据对交换位置,数据对排序
    items = [[x,y] for (y,x) in pairs]
    items.sort()

    #输出count个数词频结果
    for i in range(len(items)-1, len(items)-count-1, -1):
        print(items[i][1]+'\t'+str(items[i][0]))
        data.append(items[i][0])
        words.append(items[i][1])
    infile.close()

    #根据词频结果绘制柱状图
    turtle.title('词频结果柱状图')
    turtle.setup(900, 750, 0, 0)
    t = turtle.Turtle()
    t.hideturtle()
    t.width(3)
    drawGraph(t)
开发者ID:944624574ws,项目名称:python,代码行数:31,代码来源:dictionary.py


示例8: init

def init():
    t.setworldcoordinates(0,0,
        WINDOW_WIDTH, WINDOW_HEIGHT)
    t.up()
    t.setheading(90)
    t.forward(75)
    t.title('Typography:Name')
开发者ID:krishRohra,项目名称:PythonAssignments,代码行数:7,代码来源:typography.py


示例9: 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


示例10: main

def main():
    fileName = input('input a file name:').strip()
    infile = open(fileName, 'r')
    
    wordCounts = {}
    for line in infile:
        processline(line.lower(), wordCounts)
    
    pairs = list(wordCounts.items())
    items = [[x, y] for (y, x) in pairs]
    items.sort()
    for i in range(len(items)):
        if items[i][1] == ' ':
            items.pop(i)
    for i in range(len(items)-1, len(items)-count-1, -1):
        print(items[i][1]+'\t'+str(items[i][0]))
        data.append(items[i][0])
        words.append(items[i][1])
    infile.close()
    
    turtle.title('wordCounts chart')
    turtle.setup(900, 750, 0, 0)
    t = turtle.Turtle()
    t.hideturtle()
    t.width(3)
    
    drawGraph(t)
开发者ID:lovexleif,项目名称:python,代码行数:27,代码来源:zimuCounts.py


示例11: main

def main():
    turtle.title('数据驱动的动态路径绘制')
    turtle.setup(800,600,0,0)
    #设置画笔
    pen = turtle.Turtle()
    pen.color("red")
    pen.width(5)
    pen.shape("turtle")
    pen.speed(5)
    #读取文件
    result = []
    file = open("C:\Users\30908\Desktop\wode.txt","r")
    for line in file:
        result.append(list(map(float,line.split(","))))
    print result
    #动态绘制
    for i in range(len(result)):
        pen.color((result[i][3],result[i][4],result[i][5]))
        pen.fd(result[i][0])
        if result[i][1]:
            pen.rt(result[i][2])
        else:
            pen.lt(result[i][2])
    pen.goto(0,0)
    file.close()
开发者ID:godLYC,项目名称:hello-world,代码行数:25,代码来源:turtle.py


示例12: drawSetup

def drawSetup(title,xlimits,xscale,ylimits,yscale,axisThickness=None):
	turtle.title(title)
	xmin, xmax = xlimits
	ymin, ymax = ylimits
	#turtle.setup(xmax-xmin,ymax-ymin,0,0) #window-size
	globals()['xmin'] = xmin
	globals()['xmax'] = xmax
	globals()['ymin'] = ymin
	globals()['ymax'] = ymax
	globals()['xscale'] = xscale
	globals()['yscale'] = yscale

	turtle.setworldcoordinates(xmin,ymin,xmax,ymax)
	#turtle.speed(0) #turtle.speed() does nothing w/ turtle.tracer(0,0)
	turtle.tracer(0,0)

	drawGrid()
	#drawGridBorder()
	
	turtle.pensize(axisThickness)

	drawXaxis()
	drawXtickers()
	numberXtickers()
	
	drawYaxis()
	drawYtickers()
	numberYtickers()

	turtle.pensize(1)
开发者ID:Cacharani,项目名称:Graph-Kit,代码行数:30,代码来源:graphkit.py


示例13: __init__

    def __init__(self):
        # Janela sobre
        self.janSobre = None


        # Cor de fundo
        self.corFundo = "gray"


        turtle.screensize(1000, 700, self.corFundo)
        turtle.setup(width=1000, height=700)
        turtle.title("cidadeBela - Janela de desenho")


        turtle.speed(0)
        turtle.tracer(4)

        # Definindo variáveis globais
        self._tamPadrao = ""

        # Listas de prédios
        self.predios = ['Casa', 'Hotel']
        self.prediosProc = [ 'hotel', 'hotelInv', 'casa', 'casaInv' ]


        # Sorteando elementos
        self.sorteioPredios    = [["casa", 1], ["hotel", 1]]
        self.sorteioPrediosInv = [["casaInv", 1], ["hotelInv", 1]]


        #  Cores dos prédios
        self.coresHotel = ["076080190", "255255255", "167064057", "153204255", "000090245",
                           "201232098", "255058123", "010056150", "130255255", "255255000",
                           "255000000", "255127042", "000255000", "255170255", "000255170",
                           "212000255", "170255127", "127212255", "255127127", "255212085",
                           "212212255", "255255127", "222202144" ]
        self.coresCasa  = ['209187103', '115155225', '130047006', '255137111', '203229057',
                           '017130100', '025195159', '204057065', '194082255', '092221159',
                           '167045055', '238243030', '069241248', '000156228', '159094040',
                           '048033253', '040209239', '138164253', '190042177', '000122159',
                           '255255255', '253208201', '245228133']
        self.coresLoja  = ['255255255', '253208201', '245228133' ]

        #  Janelas dos prédios
        self.janelasHotel = janelas.janelasHotel
        self.janelasCasa  = janelas.janelasCasa
        self.janelasLoja  = janelas.janelasLoja
        self.janelasTodas = janelas.janelasTodas

        #  Tetos dos prédios
        self.tetosHotel = tetos.tetosHotel
        self.tetosCasa  = tetos.tetosCasa
        self.tetosLoja  = tetos.tetosLoja
        self.tetosTodas = tetos.tetosTodas

        #  Portas dos prédios
        self.portasHotel = portas.portasHotel
        self.portasCasa  = portas.portasCasa
        self.portasLoja  = portas.portasLoja
        self.portasTodas = portas.portasTodas
开发者ID:SrMouraSilva,项目名称:Academic-Projects,代码行数:60,代码来源:cb.py


示例14: main

def main():
    bob = turtle.Turtle()
    turtle.title('Sun Figure')
    turtle.setup(800, 800, 0, 0)
    bob.speed(0)
    bobMakesASun(bob, 1, 'purple')
    turtle.done()
开发者ID:enterth3r4in,项目名称:Shapes-,代码行数:7,代码来源:Shapes.py


示例15: main

def main():
    # set up the name of the window
    turtle.title("Polygonville")
    # setup the screen size through (1000, 650)
    # setup the initial location through (0,0)
    turtle.setup(1000,650,0,0)
    print("Welcome to Polygonville!")
    totalSides = input("Input number of sides in the polygon: ")
    while totalSides != 0:
        if totalSides < 3:
            print("Sorry, " + str(totalSides) + " is not "
            + "valid, try again or press 0 to exit")
        elif totalSides == 3:
            totalAngles = 180 * (totalSides - 2)
            sideLength = input("Put polygon sidelength: ")
            angle = totalAngles/totalSides
            func1(totalSides, sideLength, angle, totalAngles)
        else:
            totalAngles = 180 * (totalSides - 2)
            sideLength = input("Put polygon side length: ")
            angle = totalAngles/totalSides
            func2(totalSides, sideLength, angle, totalAngles)
        if totalSides > 3:
            print("Polygon Summary: \n" + 
                "Sides: " + str(totalSides) + "| Anterior Angle: " + 
                str(angle) + "| Sum of Angles: " + str(totalAngles))
        totalSides = input("\nInput number of sides in the polygon: ")
    if totalSides == 0:
        print("Thank you for using Polygonville!")
开发者ID:hifzasakhi,项目名称:Polygonville,代码行数:29,代码来源:polygonville.py


示例16: startGame

def startGame():
    '''Draws the grid ready to play the game
       Clears the grid to make sure it is empty before starting a new game
       Displays the rules/how to play to the user
       Asks the user which game mode to play by calling gameModeSelection()'''       
    
    turtle.setup(650,600)
    turtle.title("Noughts and Crosses by Genaro Bedenko")
    drawGrid()

    # Reset the gridSquares to be empty
    # This is needed for when a game has already been played and the player chose 
    # to play again, they need to play from a new grid
    for i in range(1,10):
        gridSquares[i] = 0

    displayRules()

    playSavedGame = messagebox.askquestion(title="Play Previous Game?", message="Do you want to play a previously saved game?")

    if(playSavedGame=="yes"):
        try:
            loadGame(gridSquares)

        # If the user clicks yes to play a saved game but their isn't one saved in the directory. Display a message to tell them
        # this and move on to starting a new game
        except FileNotFoundError:
            messagebox.showinfo(title="No Saved Game Available", message="There isn't a currently saved game available to play")
            gameModeSelection()
    else:
        gameModeSelection()
开发者ID:GBedenko,项目名称:introduction-to-computing-assignment,代码行数:31,代码来源:Game.py


示例17: regression

def regression():
    filename = input("Please provide the name of the file including the extention: ")
    while not (os.path.exists(filename)):
        filename = input("Please provide a valid name for the file including the extention: ")
    ds = []
    file = open(filename)

    for line in file:
        coordinates = line.split()
        x = float(coordinates[0])
        y = float(coordinates[1])
        point = (x, y)
        ds.append(point)
    my_turtle = turtle.Turtle()
    turtle.title("Least Squares Regression Line")

    turtle.clearscreen()
    xmin = min(getXcoords(ds))
    xmax = max(getXcoords(ds))
    ymin = min(getYcoords(ds))
    ymax = max(getYcoords(ds))
    xborder = 0.2 * (xmax - xmin)
    yborder = 0.2 * (ymax - ymin)
    turtle.setworldcoordinates(xmin - xborder, ymin - yborder, xmax + xborder, ymax + yborder)
    plotPoints(my_turtle, ds)
    m, b = leastSquares(ds)
    print("The equation of the line is y=%fx+%f" % (m, b))
    plotLine(my_turtle, m, b, xmin, xmax)
    plotErrorBars(my_turtle, ds, m, b)
    print("Goodbye")
开发者ID:nathnael2,项目名称:PythonPrograms,代码行数:30,代码来源:FileLinearRegression.py


示例18: init

def init():
    """
    sets the window size and the title of the program
    """
    t.setworldcoordinates(0, 0, WINDOW_LENGTH, WINDOW_HEIGHT)
    t.title('Forest')
    t.up()
    t.forward(100)
开发者ID:krishRohra,项目名称:PythonAssignments,代码行数:8,代码来源:forest.py


示例19: draw_background

def draw_background():
    t.setup(300, 500)
    t.title('Hangman')
    t.pu()
    t.setpos(-100, -200)
    t.seth(0)
    t.pd()
    t.fd(200)
开发者ID:dcbriccetti,项目名称:python-lessons,代码行数:8,代码来源:hangman.py


示例20: main

def main():
    # use sys.argv if needed
    print('generating spirograph...')
    # create parser
    descStr = """This program draws spirographs using the Turtle module. 
    When run with no arguments, this program draws random spirographs.
    
    Terminology:

    R: radius of outer circle.
    r: radius of inner circle.
    l: ratio of hole distance to r.
    """
    parser = argparse.ArgumentParser(description=descStr)
  
    # add expected arguments
    parser.add_argument('--sparams', nargs=3, dest='sparams', required=False, 
                        help="The three arguments in sparams: R, r, l.")
                        

    # parse args
    args = parser.parse_args()

    # set to 80% screen width
    turtle.setup(width=0.8)

    # set cursor shape
    turtle.shape('turtle')

    # set title
    turtle.title("Spirographs!")
    # add key handler for saving images
    turtle.onkey(saveDrawing, "s")
    # start listening 
    turtle.listen()

    # hide main turtle cursor
    turtle.hideturtle()

    # checks args and draw
    if args.sparams:
        params = [float(x) for x in args.sparams]
        # draw spirograph with given parameters
        # black by default
        col = (0.0, 0.0, 0.0)
        spiro = Spiro(0, 0, col, *params)
        spiro.draw()
    else:
        # create animator object
        spiroAnim = SpiroAnimator(4)
        # add key handler to toggle turtle cursor
        turtle.onkey(spiroAnim.toggleTurtles, "t")
        # add key handler to restart animation
        turtle.onkey(spiroAnim.restart, "space")

    # start turtle main loop
    turtle.mainloop()
开发者ID:diopib,项目名称:pp,代码行数:57,代码来源:spiro.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python turtle.tracer函数代码示例发布时间:2022-05-27
下一篇:
Python turtle.stamp函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap