Forum Archive

shape() method for turtle.py

FarmerPaco

Love that @olemoritz quietly added a turtle.py module.
Unfortunately turtle.shape() is still on the todo list.
If someone with more skill then me can help me turn the current triangle shape into a little turtle shape it would be magic to my students who are learning python3 on pythonista.
I am guessing the curent turtle shape is drawin in the
pen_tip = ui.path
Would it be as simple as painstakingly drawing a ui.path outline of a turtle shape to change the default triangle?

JonB

here is a little modification -- i used the shapes from cpython's turtle.py (though had to rotate the view another 90 deg, due to way pythonista's conevtion works). I modified PenView to have a settable shape.

https://gist.github.com/d7ec034a50f5e88e2821c94164c41a52

import turtle2
turtle=turtle2.Turtle()

turtle.color("blue","")
turtle.pendown()
for s in turtle2._pen_view._shapes:
    turtle.shape(s)
    turtle.forward(100)
    turtle.right(100)

FarmerPaco

Thanks for a quick reply. Let me take a look at this. I am really grateful.

FarmerPaco

@JonB this works beautifully. I now have little turtles all over my screen. You should share this with @olemoritz incase he feels like adding it to the turtle module in Pythonista.
Seriously, thank you.

kimptoc

+1 for more shapes :). Will look into option of getting the turtle2 lib installed on the class iPads. Perhaps I could have a one liner that references an icloud based lib, so updates can be shared easily between devices...

Yehuda Katz

Hi Farmer,
Perhaps the following code might help (the dots before 'shape' represent spaces):

from turtle import *

ht(); pu()

for i in(getshapes()):
....shape(i); stamp(); fd(43)

goto(0, -30)    
write(getshapes()) 

done()