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


Python turtle.setup方法代码示例

本文整理汇总了Python中turtle.setup方法的典型用法代码示例。如果您正苦于以下问题:Python turtle.setup方法的具体用法?Python turtle.setup怎么用?Python turtle.setup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在turtle的用法示例。


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

示例1: __init__

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import setup [as 别名]
def __init__(
                self,
                screen_width = 800,
                screen_height = 600,
                background_color = "black",
                title = "Simple Game Library by /u/wynand1004 AKA @TokyoEdTech",
                splash_time = 3):

        # Setup using Turtle module methods
        turtle.setup(width=screen_width, height=screen_height)
        turtle.bgcolor(background_color)
        turtle.title(title)
        turtle.tracer(0) # Stop automatic screen refresh
        turtle.listen() # Listen for keyboard input
        turtle.hideturtle() # Hides default turtle
        turtle.penup() # Puts pen up for defaut turtle
        turtle.setundobuffer(0) # Do not keep turtle history in memory
        turtle.onscreenclick(self.click)

        # Game Attributes
        self.SCREEN_WIDTH = screen_width
        self.SCREEN_HEIGHT = screen_height
        self.DATAFILE = "game.dat"
        self.SPLASHFILE = "splash.gif" # Must be in the same folder as game file

        self.fps = 30.0 # Lower this on slower computers or with large number of sprites
        self.title = title
        self.gravity = 0
        self.state = "showsplash"
        self.splash_time = splash_time

        self.time = time.time()

        # Clear the terminal and print the game title
        self.clear_terminal_screen()
        print (self.title)

        # Show splash
        self.show_splash(self.splash_time)

    # Pop ups 
开发者ID:wynand1004,项目名称:SPGL,代码行数:43,代码来源:spgl.py

示例2: setup_screen

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import setup [as 别名]
def setup_screen(title, background='white', screen_size_x=640, screen_size_y=320, tracer_size=200):
    print('Set up Screen')
    turtle.title(title)
    turtle.setup(screen_size_x, screen_size_y)
    turtle.hideturtle()
    turtle.penup()
    turtle.backward(240)
    turtle.tracer(tracer_size)
    turtle.bgcolor(background)  # Set the background colour of the screen 
开发者ID:johnehunt,项目名称:advancedpython3,代码行数:11,代码来源:mandelbrot.py

示例3: setup_screen

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import setup [as 别名]
def setup_screen(title, background='white', screen_size_x=640, screen_size_y=320, tracer_size=800):
    print('Set up Screen')
    turtle.title(title)
    turtle.setup(screen_size_x, screen_size_y)
    turtle.hideturtle()
    turtle.penup()
    turtle.backward(240)
    # Batch drawing to the screen for faster rendering
    turtle.tracer(tracer_size)
    turtle.bgcolor(background)  # Set the background colour of the screen 
开发者ID:johnehunt,项目名称:advancedpython3,代码行数:12,代码来源:snowflake_koch.py

示例4: setup_screen

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import setup [as 别名]
def setup_screen(title, background = 'white'):
    print('Set up Screen')
    turtle.title(title)
    turtle.setup(640, 600)
    turtle.hideturtle()
    turtle.penup()
    turtle.tracer(200)
    turtle.bgcolor(background)  # Set the background colour of the screen 
开发者ID:johnehunt,项目名称:advancedpython3,代码行数:10,代码来源:snowflake.py

示例5: setup_screen

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import setup [as 别名]
def setup_screen(title, background='white', screen_size_x=640, screen_size_y=320, tracer_size=200):
    """ Sets up Turtle screen with useful defaults """
    print('Set up Screen')
    turtle.title(title)
    turtle.setup(screen_size_x, screen_size_y)
    turtle.hideturtle()
    turtle.penup()
    turtle.backward(240)
    turtle.tracer(tracer_size)
    turtle.bgcolor(background)  # Set the background colour of the screen 
开发者ID:johnehunt,项目名称:advancedpython3,代码行数:12,代码来源:fractal_trees.py

示例6: init_pen

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import setup [as 别名]
def init_pen():
    '''
    初始化画笔的一些属性
    '''
    t.pensize(4)  # 设置画笔的大小
    t.colormode(255)  # 设置GBK颜色范围为0-255
    t.color((255, 155, 192), "pink")  # 设置画笔颜色和填充颜色(pink)
    t.setup(900, 500)  # 设置主窗口的大小为900*500
    t.speed(10)  # 设置画笔速度为10 
开发者ID:MiracleYoung,项目名称:You-are-Pythonista,代码行数:11,代码来源:xzpq.py

示例7: __init__

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import setup [as 别名]
def __init__(
                self,
                screen_width = 800,
                screen_height = 600,
                background_color = "black",
                title = "Simple Game Library by /u/wynand1004 AKA @TokyoEdTech",
                splash_time = 3):

        # Setup using Turtle module methods
        turtle.setup(width=screen_width, height=screen_height)
        turtle.bgcolor(background_color)
        turtle.title(title)
        turtle.tracer(0) # Stop automatic screen refresh
        turtle.listen() # Listen for keyboard input
        turtle.hideturtle() # Hides default turtle
        turtle.penup() # Puts pen up for defaut turtle
        turtle.setundobuffer(0) # Do not keep turtle history in memory
        turtle.onscreenclick(self.click)

        # Game Attributes
        self.FPS = 30.0 # Lower this on slower computers or with large number of sprites
        self.SCREEN_WIDTH = screen_width
        self.SCREEN_HEIGHT = screen_height
        self.DATAFILE = "game.dat"
        self.SPLASHFILE = "splash.gif" # Must be in the same folder as game file

        self.title = title
        self.gravity = 0
        self.state = "showsplash"
        self.splash_time = splash_time

        self.time = time.time()

        # Clear the terminal and print the game title
        self.clear_terminal_screen()
        print (self.title)

        # Show splash
        self.show_splash(self.splash_time)

    # Pop ups 
开发者ID:wynand1004,项目名称:SPGL,代码行数:43,代码来源:spgl.py

示例8: setup_window

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import setup [as 别名]
def setup_window():
    # Set up the window
    turtle.title('Circles in My Mind')
    turtle.setup(WIDTH, HEIGHT, 0, 0)
    turtle.colormode(255)  # Indicates RGB numbers will be in the range 0 to 255
    turtle.hideturtle()
    # Batch drawing to the screen for faster rendering
    turtle.tracer(2000)

    # Speed up drawing process
    turtle.speed(10)
    turtle.penup() 
开发者ID:johnehunt,项目名称:advancedpython3,代码行数:14,代码来源:circles-picture.py

示例9: main

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import setup [as 别名]
def main():
    # use sys.argv if needed
    print('genterating 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) # 创建参数解析器对象

    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 image
    turtle.onkey(saveDrawing,"s")
    # start listening
    turtle.listen()

    # hide main turtle cursor
    turtle.hideturtle()

    # checks args and draw # 首先检查是否有参数赋给--sparams.如果有,就从字符串中提取他们,用“列表解析”将他们转换成浮点数
    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:
        # creat animator object
        spiroAnim=SpiroAnimator(4)
        # add key handler to toggle turtle cursor
        turtle.onkey(spiroAnim.toggleTurtles,"t")
        # add key handler to toggle turtle cursor
        turtle.onkey(spiroAnim.restart,"space")

    # start turtle main loop

        turtle.mainloop()


# call main 
开发者ID:DeqianBai,项目名称:Python-Project,代码行数:60,代码来源:spiro.py


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