Questions tagged [python-turtle]

The python turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways.

1351 questions
42
votes
2 answers

Turtle module - Saving an image

I would like to figure out how to save a bitmap or vector graphics image after creating a drawing with python's turtle module. After a bit of googling I can't find an easy answer. I did find a module called canvas2svg, but I'm very new to python…
jjclarkson
  • 5,890
  • 6
  • 40
  • 62
28
votes
3 answers

How to speed up python's 'turtle' function and stop it freezing at the end

I have written a turtle program in python, but there are two problems. It goes way too slow for larger numbers, I was wonder how I can speed up turtle. It freezes after it finishes and when clicked on, says 'not responding' This is my code so…
clickonMe
  • 521
  • 2
  • 6
  • 12
21
votes
5 answers

What does bad color sequence mean in Python turtle?

I am using python turtle for a project where I need turtle to draw characters. However, when I try to use the RGB value for a color, I keep getting an error message. The input is: turtle.color((151,2,1)) followed by a series of movements. However,…
derpyherp
  • 455
  • 4
  • 9
  • 18
11
votes
4 answers

How to fully delete a turtle

I made a small tkinter game that uses turtle for graphics. It's a simulation of the Triangle Peg Game from Cracker Barrel that is able to tell the player the next best move to make at any point in the game, among other features. Pegs are just…
10
votes
2 answers

AttributeError: partially initialized module 'turtle' has no attribute 'Turtle' (most likely due to a circular import)

Does anybody have any idea why this code doesn't work? import turtle test = turtle.Turtle() test.color("orange") test.pensize(5) test.shape("turtle") test.forward(100) I use python 3.8
Sahil Forough
  • 109
  • 1
  • 1
  • 5
9
votes
1 answer

How can I change the size of my python turtle window?

I am currently trying to draw a Mandelbrot set in python with turtle. However, my problem has nothing to do with the Mandelbrot. I can't change the size of my turtle window. How can I do that? I tried to initialize a screen and set the screen size…
Nils Walker
  • 159
  • 1
  • 1
  • 9
7
votes
4 answers

How to get the position of the turtle?

How can I find the coordinate of a turtle in python? For example, if the turtle is located at (200, 300), how would I retrieve that position?
User9123
  • 596
  • 2
  • 7
  • 14
7
votes
2 answers

Get mouse click coordinates in Python turtle

I am trying to get the coordinates of a mouse click in the turtle screen, but my code isn't working. I guess this is related to time but I tried to add a 5 seconds delay but it didn't help. Here is my code: def get_mouse_click_coor(x,y): print…
Eylon
  • 71
  • 1
  • 1
  • 3
7
votes
2 answers

Python: How to reset the turtle graphics window

I am a making a blackjack game with cards using turtle and each time I play a hand turtle just prints over the last game instead of clearing the window. Is there a method that closes the window when it is called or is there another why of doing…
Allie Hart
  • 149
  • 1
  • 3
  • 14
6
votes
0 answers

exporting python turtle drawing to video

Is there a way to export a python turtle drawing to a video? The video should contain the real-time drawing process. In particular I'm not interested in a screen-recording workaround, but a solution that would work in a headless system like a cloud…
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) …
red_panda
  • 364
  • 2
  • 18
6
votes
2 answers

Python turtle.Terminator error

When i am using turtle module to draw a circle with this simple function: def draw_shape(self): canvas = Screen() t = Turtle() t.circle(self.r) canvas.exitonclick() For the first time when i call this function it opens a new window…
user7769188
6
votes
2 answers

how to rotate text in python's turtle graphics

I want to make diagrams with python's turtle (teaching purposes). The label "values" for the y-axis should be rotated. Python's turtle has a method to write a string at current position: from turtle import * left(90) # does not help write("values",…
drumherum
  • 153
  • 3
  • 6
6
votes
3 answers

How to move turtles in Python 3 with arrow keys

I am having trouble getting my turtle to be able to follow the arrow keys, any help on how to do so would be greatly appreciated. I'm sure this question has been asked before, though I can't seem to find it, and the ones I do find are for older…
Elyad K
  • 77
  • 1
  • 2
  • 4
5
votes
1 answer

Why does python turtle graphics keep crashing/stop responding?

Whenever I try and run my program, it draws the two turtles and then the window stops responding. What I was expecting is that, until one of the pieces touches the other one based on me dragging it close to the other one, I will be able to drag both…
1
2 3
89 90