Python Language Pyglet


Pyglet is a Python module used for visuals and sound. It has no dependencies on other modules. See [][1] for the official information. [1]:

Hello World in Pyglet

import pyglet
window = pyglet.window.Window()
label = pyglet.text.Label('Hello, world',
                      font_name='Times New Roman',
                      x=window.width//2, y=window.height//2,
                      anchor_x='center', anchor_y='center')
def on_draw():

Installation of Pyglet

Install Python, go into the command line and type:

Python 2:

pip install pyglet

Python 3:

pip3 install pyglet

Playing Sound in Pyglet

sound =

Using Pyglet for OpenGL

import pyglet
from import *

win = pyglet.window.Window()

def on_draw():
    #OpenGL goes here. Use OpenGL as normal.

Drawing Points Using Pyglet and OpenGL

import pyglet
from import *

win = pyglet.window.Window()

def on_draw():
    glVertex2f(x, y) #x is desired distance from left side of window, y is desired distance from bottom of window
    #make as many vertexes as you want

To connect the points, replace GL_POINTS with GL_LINE_LOOP.