@JimSkon/

TurtleMouseClickExample

Python (with Turtle)

No description

fork
loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.5803474230700632","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"aW1wb3J0IHR1cnRsZSAgICAgCmltcG9ydCByYW5kb20gICAgICAgIAp3biA9IHR1cnRsZS5TY3JlZW4oKSAgICAgIAp3bi5iZ2NvbG9yKCdsaWdodGJsdWUnKQpzdmVhID0gdHVydGxlLlR1cnRsZSgpCgpkZWYgc3F1YXJlKHQsc2l6ZSk6CiAgZm9yIGkgaW4gcmFuZ2UoNCk6CiAgICB0LmZvcndhcmQoc2l6ZSkKICAgIHQucmlnaHQoOTApCgpkZWYgZHJhd09uQ2xpY2soeCx5KToKICBzdmVhLnVwKCkKICBzdmVhLmdvdG8oeCx5KQogIHN2ZWEuZG93bigpCiAgc3F1YXJlKHN2ZWEsMzApCgp3bi5vbmNsaWNrKGRyYXdPbkNsaWNrKQoK"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import turtle     
import random        
wn = turtle.Screen()      
wn.bgcolor('lightblue')
svea = turtle.Turtle()

def square(t,size):
  for i in range(4):
    t.forward(size)
    t.right(90)

def drawOnClick(x,y):
  svea.up()
  svea.goto(x,y)
  svea.down()
  square(svea,30)

wn.onclick(drawOnClick)

result
console