Python Wiki
No edit summary
m (Sebastian Marzjan moved page Pyglet to Modules/Pyglet)
 
(No difference)

Latest revision as of 09:08, 29 June 2016

Pyglet is a module for Python allowing OpenGL support for Python through a simple API.

Examples[]

Hello World[]

import pyglet

ourwnd = pyglet.window.Window() # create a Window object

# create a Label
label = pyglet.text.Label('Hello, Python Wiki!',
                          font_name='Times New Roman',
                          font_size=36,
                          x=ourwnd.width//2, y=ourwnd.height//2,
                          anchor_x='center', anchor_y='center')

# decorator meaning window event triggers follow
@ourwnd.event
def on_draw():
    ourwnd.clear()
    label.draw()

# Run
pyglet.app.run()

Links[]