Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# python
*.pyc
__pycache__
/dist
/build
*.egg-info/

# Virtualenv
/env/
/venv/
/.venv/
/.venv2/
/.venv3/

# IDEs
/.idea
/.vscode
88 changes: 76 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,86 @@
# pyopengltk

Tkinter - OpenGL Frame using ctypes

* [pyopengltk on Github](https://github.com/jonwright/pyopengltk)
* [pyopengltk on PyPI](https://pypi.org/project/pyopengltk/)

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

Collected together by Jon Wright, Jan 2018.

Based on the work of others
## 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.

```python
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

C + Tcl/Tk example:
http://github.com/codeplea/opengl-tcltk/
(zlib license)
Article at:
https://codeplea.com/opengl-with-c-and-tcl-tk
### Python + Tkinter (no pyopengl) example:

Python + Tkinter (no pyopengl) example:
http://github.com/arcanosam/pytkogl/
(The Code Project Open License)
Article at
http://www.codeproject.com/Articles/1073475/OpenGL-in-Python-with-TKinter
* 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

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

* Large regions of code copied from `pyopengl/Tk/__init__.py`.
7 changes: 7 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[metadata]
license_files =
LICENSE

[bdist_wheel]
# build universal wheels by default
universal=1
25 changes: 24 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,29 @@
author ='Jon Wright',
author_email = 'jonathan.wright@gmail.com',
url = 'http://github.com/jonwright/pyopengltk',
py_modules=['pyopengltk'],
license='MIT',
description="An opengl frame for pyopengl-tkinter based on ctype",
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
py_modules=['pyopengltk'],
install_requires=[
'pyopengl',
],
keywords=['opengl', 'window', 'context', 'tk', 'tkinter'],
classifiers=[
'License :: OSI Approved :: MIT License',
'Environment :: Win32 (MS Windows)',
'Environment :: X11 Applications',
'Intended Audience :: Developers',
'Topic :: Multimedia :: Graphics',
'Topic :: Multimedia :: Graphics :: 3D Rendering',
'Topic :: Scientific/Engineering :: Visualization',
'Topic :: Software Development :: Libraries :: Python Modules',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
]
)