| 1 |
|
| 2 |
"""Demonstrates how to manage two independent windows. |
| 3 |
""" |
| 4 |
|
| 5 |
import pyglet |
| 6 |
|
| 7 |
|
| 8 |
w1 = pyglet.window.Window(200, 200, caption='First window', resizable=True) |
| 9 |
w1.switch_to() |
| 10 |
s1 = pyglet.shapes.Rectangle(100, 100, 100, 100, color=(50, 50, 200)) |
| 11 |
s1.anchor_position = 50, 50 |
| 12 |
|
| 13 |
|
| 14 |
@w1.event |
| 15 |
def on_draw(): |
| 16 |
w1.clear() |
| 17 |
s1.rotation -= 0.5 |
| 18 |
s1.draw() |
| 19 |
|
| 20 |
|
| 21 |
w2 = pyglet.window.Window(300, 300, caption='Second window', resizable=True) |
| 22 |
w2.switch_to() |
| 23 |
s2 = pyglet.shapes.Rectangle(150, 150, 150, 150, color=(50, 200, 50)) |
| 24 |
s2.anchor_position = 75, 75 |
| 25 |
|
| 26 |
|
| 27 |
@w2.event |
| 28 |
def on_draw(): |
| 29 |
w2.clear() |
| 30 |
s2.rotation += 0.5 |
| 31 |
s2.draw() |
| 32 |
|
| 33 |
|
| 34 |
pyglet.app.run() |