我是编码新手,想列出单击鼠标的位置的 x 和 y 坐标以在另一个文件中使用。
import turtle
import math
t = turtle.Turtle()
wn = turtle.Screen()
def rounds(x, y):
t.setheading(t.towards(x, y)) #set x and y coord to mouse
t.up()
t.goto(x, y - 8) #move turtle to center of circle
t.setheading(0) #makes turtle face set direction
t.down()
t.begin_fill()
t.circle(8)
t.end_fill()
return x, y
def getcoord(): #draw function
turtle.onscreenclick(rounds, 1) #run round every time left click
turtle.mainloop() # loops on screen click