Python turtle.hideturtle() Examples

The following are 21 code examples of turtle.hideturtle(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module turtle , or try the search function .
Example #1
Source File: mandelbrot.py    From advancedpython3 with GNU General Public License v3.0 6 votes vote down vote up
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 
Example #2
Source File: spiro.py    From Python-Project with Apache License 2.0 6 votes vote down vote up
def saveDrawing():
    # hide the turtle cursor
    turtle.hideturtle()
    # generate unique file name
    dateStr = (datetime.now()).strftime("%d%b%Y-%H%M%S")
    fileName = 'spiro-' + dateStr
    print('saving drawing to %s.eps/png' % fileName)
    # get tkinter canvas
    canvas = turtle.getcanvas()
    # save postscript image
    canvas.postscript(file=fileName + '.eps')
    # use PIL to convert to PNG
    img = Image.open(fileName + '.eps')
    img.save(fileName + '.png', 'png')
    # show turtle
    turtle.showturtle()


# main()function 
Example #3
Source File: spiro.py    From Python-Project with Apache License 2.0 6 votes vote down vote up
def update(self):

        # skip the rest of the steps if done
        if self.drawingComplete:
            return
        # increment the angle
        self.a+=self.step
        R,k,l=self.R, self.k, self.l
        # set the angle
        a=math.radians(self.a)
        x=self.R*((1 - k) * math.cos(a) + l * math.cos((1 - k) * a / k))
        y = R * ((1 - k) * math.sin(a) - l * math.sin((1 - k) * a / k))
        self.t.setpos(self.xc+x, self.yc+y)
        # if drawing is complete,set the flag
        if self.a>=360*self.nRot:
            self.drawingComplete=True
            # drawing is now done so hide the turtle cursor
            self.t.hideturtle()


    # clear everything 
Example #4
Source File: spgl.py    From SPGL with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self,
                text,
                color,
                x = 0,
                y = 0,
                font_name = "Arial",
                font_size = 12,
                font_type = "normal",
                align = "left"):

        turtle.Turtle.__init__(self)
        self.hideturtle()
        self.penup()
        self.goto(x, y)
        self.color(color)
        self.font = (font_name, font_size, font_type)
        self.align = align

        # Attributes
        self.text = text


        # Append to master label list
        Game.labels.append(self) 
Example #5
Source File: spgl.py    From SPGL with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #6
Source File: snowflake_koch.py    From advancedpython3 with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #7
Source File: spiro.py    From Python-Project with Apache License 2.0 5 votes vote down vote up
def toggleTurtles(self):
        for spiro in self.spiros:
            if spiro.t.isvisible():
                spiro.t.hideturtle()

            else:
                spiro.t.showturtle() 
Example #8
Source File: snowflake.py    From advancedpython3 with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #9
Source File: spiro.py    From Python-Project with Apache License 2.0 5 votes vote down vote up
def draw(self):
        # draw the reset of the points
        R, k, l = self.R, self.k, self.l
        for i in range(0,360*self.nRot+1,self.step):
            a=math.radians(i)
            x = R * ((1 - k) * math.cos(a) + l * math.cos((1 - k) * a / k))
            y = R * ((1 - k) * math.sin(a) - l * math.sin((1 - k) * a / k))
            self.t.setpos(self.xc+x,self.yc+y)
            # drawing is now done so hide the turtle cursor
            self.t.hideturtle()


    # update by one step 
Example #10
Source File: spgl.py    From Projects with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self,
                shape,
                color,
                x = 0,
                y = 0):

        turtle.Turtle.__init__(self)
        # self.hideturtle()
        self.penup()
        # Register shape if it is a .gif file
        if shape.endswith(".gif"):
            try:
                turtle.register_shape(shape)
            except:
                Game.logs.append("Warning: {} file missing from disk.".format(shape))

                # Set placeholder shape
                shape = "square"

        self.shape(shape)
        self.color(color)
        self.goto(x, y)

        #Set click binding
        self.onclick(self.click)

        # Append to master button list
        Game.buttons.append(self) 
Example #11
Source File: spgl.py    From Projects with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self,
                text,
                color,
                x = 0,
                y = 0,
                font_name = "Arial",
                font_size = 12,
                font_type = "normal",
                align = "left"):

        turtle.Turtle.__init__(self)
        self.hideturtle()
        self.penup()
        self.goto(x, y)
        self.color(color)
        self.font_name = font_name
        self.font_size = font_size
        self.font_type = font_type
        self.font = (font_name, font_size, font_type)
        self.align = align

        # Attributes
        self.text = text

        # Append to master label list
        Game.labels.append(self) 
Example #12
Source File: spgl.py    From Projects with GNU General Public License v3.0 5 votes vote down vote up
def destroy(self):
        # When a sprite is destoyed move it off screen, hide it, and set state to None
        # This is a workaround as there is no way to delete a sprite from memory in the turtle module.
        self.hideturtle()
        self.goto(10000, 10000)
        self.state = None 
Example #13
Source File: spgl.py    From Projects with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #14
Source File: spgl.py    From SPGL with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self,
                shape,
                color,
                x = 0,
                y = 0):

        turtle.Turtle.__init__(self)
        # self.hideturtle()
        self.penup()
        # Register shape if it is a .gif file
        if shape.endswith(".gif"):
            try:
                turtle.register_shape(shape)
            except:
                Game.logs.append("Warning: {} file missing from disk.".format(shape))

                # Set placeholder shape
                shape = "square"

        self.shape(shape)
        self.color(color)
        self.goto(x, y)

        #Set click binding
        self.onclick(self.click)

        # Append to master button list
        Game.buttons.append(self) 
Example #15
Source File: spgl.py    From SPGL with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #16
Source File: spgl.py    From SPGL with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self,
                shape,
                color,
                x = 0,
                y = 0):

        turtle.Turtle.__init__(self)
        # self.hideturtle()
        self.penup()
        # Register shape if it is a .gif file
        if shape.endswith(".gif"):
            try:
                turtle.register_shape(shape)
            except:
                Game.logs.append("Warning: {} file missing from disk.".format(shape))

                # Set placeholder shape
                shape = "square"

        self.shape(shape)
        self.color(color)
        self.goto(x, y)

        #Set click binding
        self.onclick(self.click)

        # Append to master button list
        Game.buttons.append(self) 
Example #17
Source File: spgl.py    From SPGL with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self,
                text,
                color,
                x = 0,
                y = 0,
                font_name = "Arial",
                font_size = 12,
                font_type = "normal",
                align = "left"):

        turtle.Turtle.__init__(self)
        self.hideturtle()
        self.penup()
        self.goto(x, y)
        self.color(color)
        self.font_name = font_name
        self.font_size = font_size
        self.font_type = font_type
        self.font = (font_name, font_size, font_type)
        self.align = align

        # Attributes
        self.text = text

        # Append to master label list
        Game.labels.append(self) 
Example #18
Source File: spgl.py    From SPGL with GNU General Public License v3.0 5 votes vote down vote up
def destroy(self):
        # When a sprite is destoyed move it off screen, hide it, and set state to None
        # This is a workaround as there is no way to delete a sprite from memory in the turtle module.
        self.hideturtle()
        self.goto(10000, 10000)
        self.state = None 
Example #19
Source File: fractal_trees.py    From advancedpython3 with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #20
Source File: circles-picture.py    From advancedpython3 with GNU General Public License v3.0 4 votes vote down vote up
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() 
Example #21
Source File: spiro.py    From Python-Project with Apache License 2.0 4 votes vote down vote up
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