Questions tagged [turtle-graphics]

A method for drawing computer graphics using a cursor, known as a turtle. Turtle-graphics supports game development, visualizations, animation, etc.

A method for drawing graphics, which uses a cursor (known as a turtle) for specifying the position, the direction and the attributes (color, line width, etc.) of the lines being drawn. It was popularized by the Logo programming language. Similar functionality can currently be found in Python's turtle module, which is part of its standard library.

The turtle runs commands sent to it sequentially, including moving forwards or backwards, turning/rotating, and raising or lowering "the pen" determining if the turtle is currently drawing a line while moving. This output pathway of the turtle can additionally be post-processed into 3-dimensional models. Depending upon the implementation, the turtle may traverse 2D, 3D, or N-dimensional coordinate spaces.

3188 questions
7
votes
3 answers

python turtle weird cursor jump

I am trying to use turtle draw with mouse, I got below demo code works but cursor jump sometimes during mouse move: #!/usr/bin/env python import turtle import sys width = 600 height = 300 def gothere(event): turtle.penup() x = event.x y…
lucky1928
  • 8,708
  • 10
  • 43
  • 92
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

Convert images drawn by turtle to PNG in Python

I'm making a abstract art template generator in Python that takes inputs of minimum radius, maximum radius, and number of circles. It draws random circles in random places, also meeting the user's specifications. I want to convert the Turtle…
TimRin
  • 105
  • 1
  • 1
  • 8
7
votes
2 answers

Weird Terminator error when running Python 3 Turtle in OS X

When I run a turtle graphics cell and draw some stuff its alright, but if I close the window and run the cell again I get a weird error called Terminator, and I have to restart the kernel in order to be able to run the cell again. It also happens to…
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
7
votes
2 answers

Turtle Module in python not importing

this is my fist time using the turtle module in python but i can't seem to import it? Here's my code: from turtle import * pen1 = Pen() pen2 = Pen() pen1.screen.bgcolour("#2928A7") and here is the error I get: Traceback (most recent call last): …
J.L
  • 73
  • 1
  • 1
  • 5
7
votes
2 answers

adding an image to the Turtle Screen

How can I add image to my Turtle Screen using turtle graphics? whenever I use the function addshape I keep getting errors. does turtle graphics got any other way loading/importing images? for example: import turtle screen =…
Liron Lavi
  • 421
  • 1
  • 5
  • 16
7
votes
1 answer

mathematical limits in python?

I am trying to do mathematical limits in python. I have defined a function for smoke import turtle t = turtle.Pen() def drawsmoke(y): i = 0 while i < ((2 * y) - 1): t.seth(i * 5) t.circle((10 + i), 160) i = i +…
user2095044
  • 223
  • 3
  • 6
  • 12
7
votes
1 answer

Turtle Graphics as a Haskell Monad

I'm trying to implement turtle graphics in Haskell. The goal is to be able to write a function like this: draw_something = do forward 100 right 90 forward 100 ... and then have it produce a list of points (maybe with additional…
iliis
  • 878
  • 8
  • 19
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
1 answer

Python Turtle Write Value in Containing Box

I want to be able to create some turtles which display values by subclassing turtle.Turtle. These turtles should display their value as text centered in their own shape. I also want to be able to position the turtles with accuracy, so…
Robin Andrews
  • 3,514
  • 11
  • 43
  • 111
6
votes
2 answers

E1101:Module 'turtle' has no 'forward' member

I'm new to programming and I downloaded Python and got it running in Visual Studio Code. I was messing around with the turtle module and its functions. The functions themselves work but pylint marks it as an error and says that there isn't a…
bulldogs586
  • 69
  • 1
  • 4
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