Show More
@@ -1,29 +1,33 b'' | |||
|
1 | 1 | #!/usr/bin/env python |
|
2 | 2 | """Simple pyglet example to manually test event loop integration. |
|
3 | 3 | |
|
4 | 4 | This is meant to run tests manually in ipython as: |
|
5 | 5 | |
|
6 | 6 | In [5]: %gui pyglet |
|
7 | 7 | |
|
8 | 8 | In [6]: %run gui-pyglet.py |
|
9 | 9 | """ |
|
10 | 10 | |
|
11 | 11 | import pyglet |
|
12 | 12 | |
|
13 | 13 | |
|
14 | 14 | window = pyglet.window.Window() |
|
15 | 15 | label = pyglet.text.Label('Hello, world', |
|
16 | 16 | font_name='Times New Roman', |
|
17 | 17 | font_size=36, |
|
18 | 18 | x=window.width//2, y=window.height//2, |
|
19 | 19 | anchor_x='center', anchor_y='center') |
|
20 | 20 | @window.event |
|
21 | def on_close(): | |
|
22 | window.close() | |
|
23 | ||
|
24 | @window.event | |
|
21 | 25 | def on_draw(): |
|
22 | 26 | window.clear() |
|
23 | 27 | label.draw() |
|
24 | 28 | |
|
25 | 29 | try: |
|
26 | 30 | from IPython.lib.inputhook import enable_pyglet |
|
27 | 31 | enable_pyglet() |
|
28 | 32 | except ImportError: |
|
29 | 33 | pyglet.app.run() |
General Comments 0
You need to be logged in to leave comments.
Login now