| 1 | import pyglet |
| 2 | |
| 3 | """Simple example demonstrating how to get the text in the clipboard as well as putting text in the clipboard.""" |
| 4 | |
| 5 | window = pyglet.window.Window() |
| 6 | print("Existing Clipboard Text:", window.get_clipboard_text()) |
| 7 | |
| 8 | |
| 9 | @window.event |
| 10 | def on_key_press(symbol, modifiers): |
| 11 | print("Clipboard changed to: Hello World!") |
| 12 | |
| 13 | window.set_clipboard_text("Hello World!") |
| 14 | |
| 15 | print("Clipboard Text:", window.get_clipboard_text()) |
| 16 | |
| 17 | |
| 18 | @window.event |
| 19 | def on_draw(): |
| 20 | window.clear() |
| 21 | |
| 22 | |
| 23 | pyglet.app.run() |