getMouse()
The GraphWin method that waits until the user clicks in the window and returns the click position as a Point.
In more detail
checkMouse is the non-waiting version: it returns the last click Point or None straight away, so an animation loop can keep running while watching for clicks. Waiting for a click before close gives the user time to see the result.
Example
p = win.getMouse()
print(p.getX(), p.getY())Related terms
- GraphWin — The graphics.py class for a window you can draw in, created as GraphWin(title, width, height).
- Point — The graphics.py object for a single position, made with Point(x, y), used to place and size other shapes.
- event-driven programming — A style where a program waits for events such as clicks or key presses and runs code in response, instead of following one fixed sequence.
Taught in
- Sample Graphics Programs — Hands-on Python: Complete Video Course & Book
- Reading The graphics.py Documentation — Hands-on Python: Complete Video Course & Book
- Animation: Loops, Bouncing, Flushing — Hands-on Python: Complete Video Course & Book
- Entry Objects — Hands-on Python: Complete Video Course & Book
- Graphical Applications With While — Hands-on Python: Complete Video Course & Book