omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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.


    Script does not run like it should on pythonista

    Pythonista
    2
    2
    1036
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • trezor
      trezor last edited by

      # 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.
      1 Reply Last reply Reply Quote 0
      • ccc
        ccc last edited by

        https://forum.omz-software.com/search/Turtle has always been a bit incomplete in Pythonista.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Powered by NodeBB Forums | Contributors