Skip to main content

An opengl frame for pyopengl-tkinter based on ctype

Project description


Tkinter - OpenGL Frame using ctypes

An opengl frame for pyopengl-tkinter based on ctypes (no togl compilation)

Collected together by Jon Wright, Jan 2018.

Basic Example

This example creates a window containing an OpenGLFrame filling the entire window. We configure it to animate (constantly redraw) clearing the screen using a green color. A simple framerate counter is included. The context information is printed to the terminal.

import time
import tkinter
from OpenGL import GL
from pyopengltk import OpenGLFrame

class AppOgl(OpenGLFrame):

    def initgl(self):
        """Initalize gl states when the frame is created"""
        GL.glViewport(0, 0, self.width, self.height)
        GL.glClearColor(0.0, 1.0, 0.0, 0.0)    
        self.start = time.time()
        self.nframes = 0

    def redraw(self):
        """Render a single frame"""
        tm = time.time() - self.start
        self.nframes += 1
        print("fps",self.nframes / tm, end="\r" )

if __name__ == '__main__':
    root = tkinter.Tk()
    app = AppOgl(root, width=320, height=200)
    app.pack(fill=tkinter.BOTH, expand=tkinter.YES)
    app.animate = 1
    app.after(100, app.printContext)

The repository on Github also contains more examples.


From PyPI:

pip install pyopengltk

From source:

git clone
cd pyopengltk
pip install .


Based on the work of others.

C + Tcl/Tk example:

Python + Tkinter (no pyopengl) example:


  • Large regions of code copied from pyopengl/Tk/

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyopengltk, version 0.0.3
Filename, size File type Python version Upload date Hashes
Filename, size pyopengltk-0.0.3-py2.py3-none-any.whl (12.0 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size pyopengltk-0.0.3.tar.gz (10.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page