Skip to main content

pyopengltk

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"""
        GL.glClear(GL.GL_COLOR_BUFFER_BIT)
        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)
    app.mainloop()

The repository on Github also contains more examples.

Install

From PyPI:

pip install pyopengltk

From source:

git clone https://github.com/jonwright/pyopengltk
cd pyopengltk
pip install .

Attributions

Based on the work of others.

C + Tcl/Tk example:

Python + Tkinter (no pyopengl) example:

pyopengl

  • Large regions of code copied from pyopengl/Tk/__init__.py.

Metadata

Release files for pyopengltk 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyopengltk 0.0.3
File Size Uploaded Provenance Actions
pyopengltk-0.0.3.tar.gz 10.3 kB Without provenance Details for pyopengltk-0.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyopengltk 0.0.3
File Interpreter ABI Platform Actions
pyopengltk-0.0.3-py2.py3-none-any.whl Python 2, Python 3 none any Details for pyopengltk-0.0.3-py2.py3-none-any.whl

Total release size: 22.2 kB

Release files / pyopengltk-0.0.3.tar.gz

Download URL pyopengltk-0.0.3.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
31f93c50cecf168742cc6767afa19b4953f7257ca0a41be1ad39490455cfc6f2
BLAKE2b-256 checksum
How to use checksums
a5248d7bf9d942d0902931bf15ee22f8538a7bf68c46b3f918500fd81cb5b31a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.15

Release files / pyopengltk-0.0.3-py2.py3-none-any.whl

Download URL pyopengltk-0.0.3-py2.py3-none-any.whl
Size 12.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
fa01a3fcbe281ae52b13736c2f9b5249d2c2e94f005d591d5df390774ceec79a
BLAKE2b-256 checksum
How to use checksums
3f7d2d1b9393d7f1a5f9c3fd676ff5a606efeea772dbb872f3e93716d9fb4ce4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.15

Security for pyopengltk 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page