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:
- Project URL : http://github.com/codeplea/opengl-tcltk/ (zlib license)
- Article at : https://codeplea.com/opengl-with-c-and-tcl-tk
Python + Tkinter (no pyopengl) example:
- Project URL : http://github.com/arcanosam/pytkogl/ (The Code Project Open License)
- Article at: http://www.codeproject.com/Articles/1073475/OpenGL-in-Python-with-TKinter
pyopengl
- Large regions of code copied from
pyopengl/Tk/__init__.py.
Metadata
Release files for pyopengltk 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyopengltk-0.0.4.tar.gz | 11.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyopengltk-0.0.4-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 23.2 kB
Release files / pyopengltk-0.0.4.tar.gz
| Download URL | pyopengltk-0.0.4.tar.gz |
|---|---|
| Size | 11.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4ec9bd44e5b3a8a4f3901d611b572c6d55463450ecf7d20bc51c00771b669650
|
|
BLAKE2b-256 checksum How to use checksums |
b90f6a7466103b044b36f5ab3784fccf7e348bd0a1670fea58ded840c03f51f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.8.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
|
Release files / pyopengltk-0.0.4-py2.py3-none-any.whl
| Download URL | pyopengltk-0.0.4-py2.py3-none-any.whl |
|---|---|
| Size | 12.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
664c9c97e7f24d7664f4560064e4a4dc8a40880337483080f1b2937de052379e
|
|
BLAKE2b-256 checksum How to use checksums |
7e7f09782e32c071d4774321b9f8349a5e0f11258930e03a28ffb6c978cbe4b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.8.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
|