Ich versuche, ein Programm, das den Benutzer fragt, um eine Form und wie viele dieser Form in Python-Schildkröte zu zeichnen. Ich weiß nicht, wie man die Dialogbox macht, damit der Benutzer sagen kann, wie viele hinzuzufügen und es richtig laufen lassen. Jede Hilfe wird großartig sein! Hier ist mein Code so weit:Frage Benutzer, welche Form zu zeichnen und wie viele in Python Schildkröte
import turtle
steps = {"triangle": 3, "square": 4, "pentagon": 5, "hexagon": 6, "octagon": 7}
#this is the dialogue box for what shape to draw and moving it over a bit so the
#next shape can be seen
def onkey_shape():
shape = turtle.textinput("Enter a shape", "Enter a shape: triangle,
square, pentagon, hexagon, octagon")
if shape.lower() in steps:
turtle.forward(20)
set_shape(shape.lower())
turtle.listen()
def set_shape(shape):
global current_shape
turtle.circle(40, None, steps[shape])
current_shape = shape
turtle.onkey(onkey_shape, "d")
turtle.listen()
turtle.mainloop()
FANTASTISCH Vielen Dank! Das ist genau das, was ich brauchte! –