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