Last active
December 10, 2015 23:18
-
-
Save hortonew/4507878 to your computer and use it in GitHub Desktop.
Pyglet - Mouse Handling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyglet | |
screen = pyglet.window.Window(800, 600) | |
@screen.event | |
def on_mouse_motion(x, y, dx, dy): | |
#print current mouse position | |
print x,y | |
@screen.event | |
def on_mouse_press(x, y, button, modifiers): | |
#when a user presses a mouse button, print which one and where the mouse is | |
print "{0} pressed at: {1},{2}.".format(button, x, y) | |
if __name__ == "__main__": | |
pyglet.app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment