turtle.rt(130)
turtle.clear () turtle.done ()
### `write(arg, move=False, align='left', font=('Arial', 8, 'normal'))`
Writes the string `arg` at the current turtle position. The text can be moved with the turtle if `move` is `True`. The `align` parameter can be set to `'left'`, `'center'`, or `'right'`. The `font` is a tuple specifying the font name, size, and type (e.g., `'normal'`, `'bold'`, `'italic'`).
- `arg` -- string to be written
- `move` -- boolean
- `align` -- string
- `font` -- tuple
```python
import turtle
turtle.write("Hello, Turtle!", move=True, align='center', font=('Arial', 16, 'bold'))
turtle.done()
showturtle() | st()
Makes the turtle visible.
hideturtle() | ht()
Makes the turtle invisible.
isvisible()
Returns True if the turtle is visible, otherwise False.
Screen Control
bgcolor(*args)
Sets or returns the background color of the turtle screen. Can be called in the following ways:
bgcolor(colorstring)-- color string (e.g.,"red","#ff0000")bgcolor((r, g, b))-- color tuple. Each of r, g, and b should be in the range 0.1 or 0.255, depending on the color mode (seecolormode())bgcolor(r, g, b)-- color numbers. Each of r, g, and b should be in the range 0.1 or 0.255, depending on the color mode (seecolormode())
import turtle
turtle.bgcolor("lightblue")
turtle.done()
bgpic(picname=None)
Sets or returns the background image of the turtle screen. If called without arguments, returns the current background image.
picname-- string (filename of the image)
import turtle
turtle.bgpic("background.gif")
turtle.done()
title(titlestring)
Sets the title of the turtle graphics window.
titlestring-- string
import turtle
turtle.title("My Turtle Program")
turtle.done()
bye()
Closes the turtle graphics window.
import turtle
turtle.bye()
screensize(canvwidth=None, canvheight=None, bg=None)
Sets or returns the size of the turtle graphics window. If called without arguments, returns the current canvas size.
canvwidth-- integercanvheight-- integerbg-- color string or tuple
import turtle
turtle.screensize(800, 600, "yellow")
turtle.done()
tracer(n=None, delay=None)
Turns turtle animation on or off and sets a delay for updates. If n is 0, no animation occurs. If n is greater than 1, updates are made every nth screen update. delay is the time in milliseconds between updates.
n-- integerdelay-- integer
import turtle
turtle.tracer(0, 0)
for i in range(36):
turtle.fd(100)
turtle.rt(170)
turtle.update()
turtle.done()
update()
Performs a turtle screen update. Used when tracer is turned off.
import turtle
turtle.tracer(0, 0)
for i in range(36):
turtle.fd(100)
turtle.rt(170)
turtle.update()
turtle.done()