Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

310
Views
How to get coordinates of current mouse position in Python?

I want to make a program using Python Turtle, that moves the turtle to mouse coordinates while clicking. But I don't know how to write a function that returns mouse position. Or, if it will be more understandable, there is HTML and JavaScript code to convert into Python code:

function getcoords(event)
{
  console.log(event.clientX + " " + event.clientY);
}

addEventListener("click", getcoords)
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

According to this answer, you can use the code below:

canvas = turtle.getcanvas()
x, y = canvas.winfo_pointerx(), canvas.winfo_pointery()
about 4 years ago · Juan Pablo Isaza Report

0

The Python logic is pretty much the same as your Javascript logic:

from turtle import Screen

def getcoords(x, y):
    print(x, y)

screen = Screen()

screen.onclick(getcoords)

screen.mainloop()
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!