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
5
votes
1 answer

Python turtle.setup() truncates canvas to screen size - how to avoid that?

To measure the rotation speed of a rod, I need to make a dial with a large number of alternating dark / transparent segments arranged in a circle. The rotating dial will interrupt the light on a photosensor, and then I only need to measure the…
Florin Andrei
  • 1,067
  • 3
  • 11
  • 33
5
votes
6 answers

Multithreading With Python Turtle

Is there a way to use two turtles at the same time to draw two circles at the same time in one window? I tried this code but two turtles draw in separated windows from multiprocessing import Process import…
hamidfzm
  • 4,595
  • 8
  • 48
  • 80
5
votes
1 answer

Turtle in python- Trying to get the turtle to move to the mouse click position and print its coordinates

I'm trying to get the mouse position through Python turtle. Everything works except that I cannot get the turtle to jump to the position of the mouse click. import turtle def startmap(): #the next methods pertain to drawing the map …
jfa
  • 1,047
  • 3
  • 13
  • 39
5
votes
2 answers

Python Turtle window with scrollbars

I am new to Python, and have written a simple program in Python 2.7 using turtle graphics, which draws a fractal shape. The problem I have is that the turtle window doesn't have scrollbars, so if the shape is too large for the window, it is…
nixey26
  • 91
  • 1
  • 4
4
votes
3 answers

How to create a subclass in python that is inherited from turtle Module

So, i'm trying to learn python and every time i post a question here it feels like giving in... I'm trying to make my own class of turtle.Turtle. import turtle class TurtleGTX(turtle.Turtle): """My own version of turtle""" def…
Drew Verlee
  • 1,880
  • 5
  • 21
  • 30
4
votes
1 answer

Python imaging, resize Turtle Graphics window

My image is too large for the turtle window. I had to enlarge the image because the text I need at each spot overlaps. How do I Resize the window in python?
TIMBERings
  • 165
  • 1
  • 2
  • 8
4
votes
2 answers

Overlapping trees in L-system forest

I created an a program using python's turtle graphics that simulates tree growth in a forest. There's 3 tree patterns that are randomly chosen, and their starting coordinates and angles are randomly chosen as well. I chose some cool looking tree…
mdegges
  • 963
  • 3
  • 18
  • 39
4
votes
3 answers

Hide Turtle Window?

I am generating diagrams in Turtle, and as part of my program, I identify certain coordinates from my diagrams. I would like to be able to hide the complete turtle window, since I only care about the coordinates, is that possible? Edit: QUESTION…
ElectroNerd
  • 375
  • 1
  • 6
  • 18
4
votes
3 answers

Hiding the turtle in python turtle drawing

I am trying to make it so that the turtle is hidden from the beginning of the program but even after putting t.hideturtle() right below where I declare the turtle as variable t the turtle still seems to show up in the middle of the drawing. import…
nickg
  • 123
  • 5
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 =…
Matt
  • 134
  • 10
4
votes
1 answer

restoring recorded state in l-system code using turtle graphics

I'm using turtle graphics to reproduce l-systems (TurtleWorld library). The rules I have tried to apply work well when they don't involve going back to a previous saved state, but whenever there is a [ and ] (see rule below), things break and the…
L-R
  • 1,214
  • 1
  • 19
  • 40
4
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…
Red
  • 26,798
  • 7
  • 36
  • 58
4
votes
3 answers

How can I change turtle images in order every time I press the same button in Python?

I want to write a program that changes the turtle image in order each time I press the 'n' key. It should first start with the 'classic' shape, and every time the 'n' key is pressed, change the shape to 'circle', 'arrow', 'turtle' and then loop back…
René
  • 43
  • 2
4
votes
4 answers

Using turtle graphics in Google colab

I am working with a student that uses Google colab. I tried introducing her to turtle graphics. We got this error: TclError: no display name and no $DISPLAY environment variable. When I try to look up the error all the solutions are very specific to…
4
votes
4 answers

Is there a way to shorten my code so that I don't have to write "turtle." every time I use functions from the turtle module?

I am trying to draw squares using turtle in python, and every time I want to command it to do something I must write turtle. import…