Skip to content

Instantly share code, notes, and snippets.

@koo5
Created August 31, 2013 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koo5/6398295 to your computer and use it in GitHub Desktop.
Save koo5/6398295 to your computer and use it in GitHub Desktop.
it.py
#!/usr/bin/env python
import pyglet
window = pyglet.window.Window(resizable=True)
document = pyglet.text.document.FormattedDocument()
layout = pyglet.text.layout.IncrementalTextLayout(document, window.width, window.height, multiline=True)
caret = pyglet.text.caret.Caret(layout)
window.push_handlers(caret)
@window.event
def on_resize(width, height):
# Wrap text to the width of the window
layout.width = window.width
# Keep text vertically centered in the window
layout.y = window.height // 2
@window.event
def on_draw():
window.clear()
layout.draw()
pyglet.gl.glClearColor(1, 1, 0, 1)
pyglet.app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment