حل تحدي درس عمل واجهة رسومية للتطبيق (دائرة ، مثلث ، مربع ، خروج)

from turtle import Turtle, Screen

window = Screen()
window.setup(600, 600)
window.bgcolor(“Black”)

draw = Turtle()
draw.hideturtle()
draw.pensize(3)

ar_exiting_text = “إضغط في أي مكان للخروج”.split()
reverse_ar_exiting_text = (" ".join(ar_exiting_text[::-1]))

while True:
user_choice = window.textinput(title=“Choose a shape”,
prompt=“Choose a shape to draw (Circle - Triangle - Square):”).lower()

if user_choice == "Circle".lower() or user_choice == "دائرة":
    draw.color("Yellow")
    draw.circle(100)

elif user_choice == "Triangle".lower() or user_choice == "مثلث":
    draw.color("Purple")
    for _ in range(3):
        draw.forward(200)
        draw.left(120)

elif user_choice == "Square".lower() or user_choice == "مربع":
    draw.color("red")
    for _ in range(4):
        draw.forward(100)
        draw.left(90)

elif user_choice == "Exit".lower() or user_choice == "خروج":
    draw.screen.clear()
    window.bgcolor("Black")
    draw.penup()
    draw.color("White")
    draw.write("Press Any key to exit", align="center", font=("Algerian", 22, "bold"))
    draw.goto(0, -30)
    draw.color("Gray")
    draw.write(f"{reverse_ar_exiting_text}", align="center", font=("Algerian", 16, "bold"))
    window.exitonclick()
    break



5 إعجابات