How to Get Coordinate Of Screen in Python Turtle ?
Turtle is a special feature in python which contains a graphical library. In this article we will learn how to Get Coordinate Of Screen in Python Turtle.
Turtle has many built in function to create this program we use following.
import turtle –> This is the python library which allow us to access turtle library.
Turtle()–> This Method is used to make object.
onscreenclick(functionname,1) –> This is turtle function which sends the coordinate to function; 1 is for left click and 3 is for Right click
speed()–> This is used to increase or decrease the speed of turtle pointer.
listen()–> This allows the server to listen to incoming connections.
done()–> This is used to hold the screen.
Python3
import turtle
tess = turtle.Turtle()
def buttonclick(x,y):
print ( "You clicked at this coordinate({0},{1})" . format (x,y))
turtle.onscreenclick(buttonclick, 1 )
turtle.listen()
turtle.speed( 10 )
turtle.done()
|
Output:
Above Output shows that coordinates are print where pointer clicks on the Screen
Last Updated :
21 Jun, 2022
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...