Skip to content

Instantly share code, notes, and snippets.

@omriazulay2016-wq
Created April 8, 2026 13:49
Show Gist options
  • Select an option

  • Save omriazulay2016-wq/57a6f2dbf8955e2cec71fdaf89aafabe to your computer and use it in GitHub Desktop.

Select an option

Save omriazulay2016-wq/57a6f2dbf8955e2cec71fdaf89aafabe to your computer and use it in GitHub Desktop.
turtle draw
import turtle
turti = turtle.Turtle()
screen = turtle.Screen()
screen.listen()
is_drawing = True
text = ""
mode = "instructions"
def show_instructions():
instructions = """איך לצייר
חצים: הזז את הצב
רווח: החלף בין מצב ציור לתזוזה ללא ציור
מספרים 9-0: שנה צבעים
לחץ אנטר כדי להתחיל לצייר"""
turti.write(instructions, align="center", font=("Arial", 16, "normal"))
def start_drawing():
global mode
if mode == "drawing":
return
mode = "drawing"
turti.clear()
turti.goto(0, 0)
screen.onkey(start_drawing, "Return")
show_instructions()
def on_up():
y = turti.ycor()
turti.sety(y + 10)
screen.onkey(on_up, "Up")
def on_right():
x = turti.xcor()
turti.setx(x + 10)
screen.onkey(on_right, "Right")
def on_left():
x = turti.xcor()
turti.setx(x - 10)
screen.onkey(on_left, "Left")
def on_down():
y = turti.ycor()
turti.sety(y - 10)
screen.onkey(on_down, "Down")
def on_space():
global is_drawing
if is_drawing:
turti.penup()
else:
turti.pendown()
is_drawing = not is_drawing
screen.onkey(on_space, "space")
def color_red():
turti.color("red")
def color_blue():
turti.color("blue")
def color_green():
turti.color("green")
def color_yellow():
turti.color("yellow")
def color_purple():
turti.color("purple")
def color_orange():
turti.color("orange")
def color_pink():
turti.color("pink")
def color_cyan():
turti.color("cyan")
def color_magenta():
turti.color("magenta")
def color_black():
turti.color("black")
screen.onkey(color_red, "1")
screen.onkey(color_blue, "2")
screen.onkey(color_green, "3")
screen.onkey(color_yellow, "4")
screen.onkey(color_purple, "5")
screen.onkey(color_orange, "6")
screen.onkey(color_pink, "7")
screen.onkey(color_cyan, "8")
screen.onkey(color_magenta, "9")
screen.onkey(color_black, "0")
screen.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment