Thanks @ccc and @cvp. Seems to be impossible in Pythonista, or at least not the way I want it to do. Thanks for the customized turtle documentation!
Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Posts made by trezor
-
RE: A program that draws a spiral with the user’s name in color (using the turtle module)
-
A program that draws a spiral with the user’s name in color (using the turtle module)
I have written a little program that let’s the user enter his/her name and then draws a spiral with the name in four colors. The code works fine, but the names are not in color. I have reviewed it many times and I cannot find an error. I wonder, if the turtle module has the full functionality in Pythonista and if there are some restrictions.
Is there anybody that has some experience with the turtle module in Pythonista? Does the code seem incorrect to you? What would you change, that the names are printed in color?
Here is my code:
# SpiralMyName.py - prints a colorful spiral of the user's name import turtle t = turtle.Pen() turtle.bgcolor('white') colors = ['red', 'yellow', 'blue', 'green'] # Ask the user's name using turtle's textinput pop-up window your_name = turtle.textinput('Enter your name', 'What is your name?') # Draw a spiral of the name on the screen, written 100 times for x in range(100): t.penup() # Don't draw the regular spiral lines t.forward(x*4) # Just move the turtle on the screen t.pencolor(colors[x%4]) # Rotate through the four colors. t.pendown() # Write the user's name bigger each time. t.write(your_name, font = ('Arial', int((x+4)/4), 'bold')) t.left(92) # Turn left, just as in our other spirals.
-
Script does not run like it should on pythonista
# SpiralMyName.py - prints a colorful spiral of the user's name import turtle t = turtle.Pen() turtle.bgcolor('white') colors = ['red', 'yellow', 'blue', 'green'] # Ask the user's name using turtle's textinput pop-up window your_name = turtle.textinput('Enter your name', 'What is your name?') # Draw a spiral of the name on the screen, written 100 times for x in range(100): t.pencolor(colors[x%4]) # Rotate through the four colors. t.penup() # Don't draw the regular spiral lines t.forward(x*4) # Just move the turtle on the screen t.pendown() # Write the user's name, bigger each time t.write(your_name, font=('Arial', int((x+4)/4), 'bold')) t.left(92) # Turn left, just as in our other spirals ``` When I run this script in pythonista, the output is different to what I expected in two ways: - For some reason, the text is not written in different colors like it should. I cannot find an error in the for loop I have written. - The text should increase in size with every new loop and should be in bold. Both does not happen. The text stays in black and is all the same size. Apart from that, the program runs normally. When I run this code on my MacBook Pro the output appears like it should. I have checked my code for syntax errors with the keyword argument font, but I cannot see what I have done wrong.