-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevents.py
43 lines (30 loc) · 857 Bytes
/
events.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
"""
"""
__docformat__ = "restructuredtext"
__version__ = "$Id$"
import pyglet
from pyglet.window import key
from pyglet.window import mouse
window = pyglet.window.Window()
@window.event
def on_key_press(symbol, modifiers):
if symbol == key.A:
print('The "A" key was pressed.')
elif symbol == key.LEFT:
print("The left arrow key was pressed.")
elif symbol == key.ENTER:
print("The enter key was pressed.")
else:
print("A key was pressed.")
@window.event
def on_mouse_press(x, y, button, modifiers):
if button == mouse.LEFT:
print("The left mouse button was pressed.")
elif button == mouse.RIGHT:
print("The right mouse button was pressed.")
print("Mouse position: %d, %d" % (x, y))
@window.event
def on_draw():
window.clear()
pyglet.app.run()