-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.py
30 lines (24 loc) · 912 Bytes
/
example.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
import pyglet
from pyglet import shapes
def on_button_press():
print("Hello")
window = pyglet.window.Window()
button_label = pyglet.text.Label('Press SPACE to say Hello',
font_name='Arial',
font_size=36,
x=window.width//2, y=window.height//2,
anchor_x='center', anchor_y='center')
batch = pyglet.graphics.Batch()
square = shapes.Rectangle(window.width//2 - 50, window.height//2 - 50, 100, 100, batch=batch)
start_button = shapes.BorderedRectangle(0, 460, 150, 40, color=(20, 200, 20),border_color=(200,20,20),batch=batch)
@window.event
def on_draw():
window.clear()
batch.draw()
button_label.draw()
# @window.event
# def on_key_press(symbol, modifiers):
# print(symbol)
# if symbol == pyglet.window.key.SPACE:
# on_button_press()
pyglet.app.run()