Python Forum
Noob question: why is shapesize() not working for my turtle
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Noob question: why is shapesize() not working for my turtle
#1
Hi.
I'm just learning to code in general and starting with Python.
I'm experimenting with the turtle drawing module.

I'm trying to create a circular stamp.
My plan was to change the turtle shape to "circle" and then adjust the size of the shape, lift the pen, and use the stamp() method where needed. For some reason I'm unable to change the size of my circular shaped turtle.
I get an error: AttributeError: 'Turtle' object has no attribute 'shapesize'

Here is a simplified example of what I'm trying to do, but get the error:

import turtle
wn = turtle.Screen()

jim = turtle.Turtle()
jim.shape("circle")
jim.shapesize(50,50)
jim.stamp()
jim.up()
jim.forward(100)
I expected the jim the turtle to leave a 50x50 circular stamp in the middle of my window, but as mentioned, for some reason "shapesize" is not being recognized as an attribute of Jim the turtle.

I found the shapesize() method on this page: https://docs.python.org/3/library/turtle...rtle.shape

Does anyone maybe have a minute help me figure this out? Pray

Thanks!
Reply
#2
this code works (i.e. no error).
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
add the following statement at end:
turtle.done()
Reply
#4
you need to make some changes in the start of your code,
use
import turtle
turtle.setup(50,50)
wn=turtle.screen
Reply
#5
(Sep-09-2020, 04:09 PM)buran Wrote: this code works (i.e. no error).

Hi buran,

I'm learning with this site:
https://runestone.academy/runestone/book...cises.html

when I type the code in the code box for the last exercise (#13) I get this message:

Quote:Error
AttributeError: 'Turtle' object has no attribute 'shapesize' on line 6
Description
This error message is telling you that the object on the left hand side of the dot, does not have the attribute or method on the right hand side.

To Fix
The most common variant of this message is that the object undefined does not have attribute X. This tells you that the object on the left hand side of the dot is not what you think. Trace the variable back and print it out in various places until you discover where it becomes undefined. Otherwise check the attribute on the right hand side of the dot for a typo.
Reply
#6
well, that is strange, because when running this code locally works just fine
import turtle
wn = turtle.Screen()
 
jim = turtle.Turtle()
jim.shape("circle")
jim.shapesize(50,50)
jim.stamp()
jim.up()
jim.forward(100)
turtle.done() # added so that you can see the result
this is the result:

Attached Files

Thumbnail(s)
   
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#7
(Sep-09-2020, 06:13 PM)buran Wrote: well, that is strange, because when running this code locally works just fine
Okay, thanks at least I'm not crazy : )
Reply
#8
What version of Python are you using? What platform are you running on? How do you run your program? Have you tried using turtlesize?
Reply
#9
(Sep-09-2020, 08:15 PM)deanhystad Wrote: What version of Python are you using? What platform are you running on? How do you run your program? Have you tried using turtlesize?

I'm learning through this tutorial:
https://runestone.academy/runestone/book...cises.html

It was actually recommended by someone here in this forum.

The tutorial has these little code windows where you can type your code and execute it.

That's what I'm using for now.

I just tried substituting shapesize with turtlesize, but getting same result -
Quote:AttributeError: 'Turtle' object has no attribute 'turtlesize' on line 6

I'll assume it's something buggy in the thing that is running the code in this tutorial website, unless you think it could be something else
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Question about working with dictionaries Ashcora 13 2,008 Dec-27-2022, 09:09 PM
Last Post: Ashcora
  Function not scriptable: Noob question kaega2 3 1,172 Aug-21-2022, 04:37 PM
Last Post: kaega2
  Noob question about lists adifrank 4 2,870 Nov-19-2020, 03:26 AM
Last Post: adifrank
  Noob question adifrank 6 2,733 Aug-18-2020, 11:50 PM
Last Post: adifrank
  turtle.Screen() not working Jdawgg531 0 2,730 May-04-2020, 12:43 AM
Last Post: Jdawgg531
  setup() from turtle module not working bobfat 7 6,092 Oct-28-2019, 11:05 AM
Last Post: newbieAuggie2019
  Noob Question: Sample Data csn113 1 2,168 Feb-18-2019, 06:35 PM
Last Post: micseydel
  wn = turtle.screen() AttributeError: module 'turtle' has no attribute 'screen' Shadower 1 6,171 Feb-06-2019, 01:25 AM
Last Post: woooee
  Help! Turtle not working, even when we click the turtle demo in IDLE nothing happens. BertyBee 3 5,615 Jan-04-2019, 02:44 AM
Last Post: SheeppOSU
  Noob question on Mac python3, pydoc3 JamesNJ 0 2,305 Oct-08-2018, 04:26 AM
Last Post: JamesNJ

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020