The python turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways.
Questions tagged [python-turtle]
507 questions
6
votes
4 answers
How to prevent turtle from moving in opposite direction
Code:
import turtle
import random
import time
s = turtle.getscreen()
turtle.screensize(canvwidth=400, canvheight=400)
t = turtle.Turtle()
t.pensize(0)
t.shape('square')
t.color("black")
t.speed(0)
t.penup()
def moveu(num):
t.setheading(num)
…
![](../../users/profiles/15605589.webp)
red_panda
- 335
- 15
5
votes
2 answers
Python - Turtle recreating image too slow
I got curious and wondered if I could have the pyautogui module detect the color from every few pixels from an image and have turtle recreate them in it's canvas using small circles. I ended up finding a way to make it work, and I liked how the…
![](../../users/profiles/13736124.webp)
Jam_T
- 75
- 3
4
votes
1 answer
How do I add an image to the turtle screen without getting an error?
I have seen other people ask this question and I have looked it up. However, I still get the same error. Error: 'str' object has no attribute '_type'. Here is my code:
from turtle import *
setup(600,600)
Screen()
sc = Screen()
alien =…
![](../../users/profiles/15179044.webp)
Matt
- 124
- 10
4
votes
2 answers
Python Turtle - Turtle Location
I want to make the turtle goto the floor if it is above a set of coordinates:
something like this:
floor = -323
if turtle above floor:
turtle.goto(floor)
But I don't know how the 'if' statement would work, as you can't simply put 'if turtle…
![](../../users/profiles/6194302.webp)
A Display Name
- 327
- 8
- 18
4
votes
2 answers
Change appearance of turtle
I am programming in python 3.2.2 turtle. I am able to make the turtle follow my cursor when I clack but now I have trouble changing the appearance of the turtle. In my code you will see a tank, and I want the image of the tank to be my turtle.
Here…
![](../../users/profiles/6026944.webp)
bertrand
- 111
- 2
- 10
3
votes
3 answers
Turtle Maze in python. I do not know how to avoid the turtle passing walls and cheat
i am a complete beginner to coding and at school we started learning python. My little cousin discovered that, and asked me to make a game... since i am not an expert i decided to do a simple game, a maze.
I coded some functions to generate the maze…
![](../../users/profiles/15011884.webp)
MarcoMac01
- 31
- 1
3
votes
1 answer
How to get multiple keybindings to work simultaniously in turtle graphics?
I am making a game in python called pong.
Can I get 2 different turtles in turtle graphics to respond simultaneously to keybindings?
Here is the code:
import turtle
class paddle(turtle.Turtle):
def __init__(self, x_cord, keybindings):
…
![](../../users/profiles/14214531.webp)
game movie
- 57
- 6
3
votes
2 answers
Python Turtle transparent fill?
I'm trying to recreate this picture using the Turtle library:
but I'm struggling when trying to make the inner circles 'transparent'.
I searched the documentation but found no way to change the opacity of the circle's fill color.
What I tried…
![](../../users/profiles/12508281.webp)
Yarin B
- 33
- 3
3
votes
1 answer
How to make turtle draw quicker?
My code:
import turtle
screen = turtle.Screen()
bob = turtle.Turtle()
screen.bgcolor("black")
bob.speed(0)
def crazy():
for i in range(360):
for colors in ['red', 'yellow', 'green', 'purple', 'orange', 'blue']:
…
3
votes
2 answers
The rule of thumb as to when we should use a global variable in a function
When I code games with functions, I often get confused as to which variable to global. I've heard that globalizing variables isn't a very practice, so I try to minimize the amount by not globalizing any, and only globalize the ones that the error…
![](../../users/profiles/13552470.webp)
Ann Zen
- 17,892
- 6
- 20
- 39
3
votes
1 answer
screensize of turtle in python
I am trying to work with the screen in turtle and am confused about the dimensions of the screen. So in this example:
import turtle
screen = turtle.Screen()
print(screen.screensize())
turtle.done()
Python prints the dimension of the turtle…
![](../../users/profiles/11809811.webp)
Another_coder
- 137
- 7
3
votes
1 answer
Is there a way to change the location of a text box in turtle? It always shows up in the top left for me, but I want it in the bottom center
import turtle
screen = turtle.Screen()
global answer
answer = screen.textinput("Welcome to the game", "What's your name?")
Here is a screenshot of what comes up.
I can't seem to find anything describing a way to edit the box at all. I'm also…
![](../../users/profiles/13295438.webp)
Michelle Bronstein
- 31
- 4
3
votes
1 answer
How do I hide something a turtle drew previously?
I used turtle.write to write something on the screen. How do I hide it completely. Not the turtle icon thing, but what's written.
![](../../users/profiles/13091407.webp)
penny12
- 57
- 4
3
votes
1 answer
Can you get user input with turtle.write?
I want to ask the user a question using turtle.write and get input. Is that possible?
![](../../users/profiles/13091407.webp)
penny12
- 57
- 4
3
votes
2 answers
Don't understand this AttributeError: module 'turtle' has no attribute 'Turtle'
#archimedes spiral by rays
import math
import turtle
def spiral(t, a, b):
diff=5
number=500
for i in range(number):
t.penup()
t.fd(a+b*i*diff*math.pi/180)
t.pendown()
t.lt(90)
t.fd(10)
…
![](../../users/profiles/10066521.webp)
Manish Kumar
- 85
- 1
- 1
- 8