pyopengltk


Namepyopengltk JSON
Version 0.0.4 PyPI version JSON
download
home_pagehttp://github.com/jonwright/pyopengltk
SummaryAn opengl frame for pyopengl-tkinter based on ctype
upload_time2022-02-21 03:44:11
maintainer
docs_urlNone
authorJon Wright
requires_python
licenseMIT
keywords opengl window context tk tkinter
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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.

## 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

### 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`.



            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/jonwright/pyopengltk",
    "name": "pyopengltk",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "opengl,window,context,tk,tkinter",
    "author": "Jon Wright",
    "author_email": "jonathan.wright@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/b9/0f/6a7466103b044b36f5ab3784fccf7e348bd0a1670fea58ded840c03f51f4/pyopengltk-0.0.4.tar.gz",
    "platform": "",
    "description": "# pyopengltk\n\nTkinter - OpenGL Frame using ctypes\n\n* [pyopengltk on Github](https://github.com/jonwright/pyopengltk)\n* [pyopengltk on PyPI](https://pypi.org/project/pyopengltk/)\n\nAn opengl frame for pyopengl-tkinter based on ctypes (no togl compilation)\n\nCollected together by Jon Wright, Jan 2018.\n\n## Basic Example\n\nThis example creates a window containing an `OpenGLFrame`\nfilling the entire window. We configure it to animate\n(constantly redraw) clearing the screen using a green color.\nA simple framerate counter is included.\nThe context information is printed to the terminal.\n\n```python\nimport time\nimport tkinter\nfrom OpenGL import GL\nfrom pyopengltk import OpenGLFrame\n\nclass AppOgl(OpenGLFrame):\n\n    def initgl(self):\n        \"\"\"Initalize gl states when the frame is created\"\"\"\n        GL.glViewport(0, 0, self.width, self.height)\n        GL.glClearColor(0.0, 1.0, 0.0, 0.0)    \n        self.start = time.time()\n        self.nframes = 0\n\n    def redraw(self):\n        \"\"\"Render a single frame\"\"\"\n        GL.glClear(GL.GL_COLOR_BUFFER_BIT)\n        tm = time.time() - self.start\n        self.nframes += 1\n        print(\"fps\",self.nframes / tm, end=\"\\r\" )\n\n\nif __name__ == '__main__':\n    root = tkinter.Tk()\n    app = AppOgl(root, width=320, height=200)\n    app.pack(fill=tkinter.BOTH, expand=tkinter.YES)\n    app.animate = 1\n    app.after(100, app.printContext)\n    app.mainloop()\n```\n\nThe repository on Github also contains more examples.\n\n## Install\n\nFrom PyPI:\n\n```\npip install pyopengltk\n```\n\nFrom source:\n\n```\ngit clone https://github.com/jonwright/pyopengltk\ncd pyopengltk\npip install .\n```\n\n## Attributions\n\nBased on the work of others.\n\n### C + Tcl/Tk example:\n\n* Project URL : http://github.com/codeplea/opengl-tcltk/ (zlib license)\n* Article at : https://codeplea.com/opengl-with-c-and-tcl-tk\n\n### Python + Tkinter (no pyopengl) example:\n\n* Project URL : http://github.com/arcanosam/pytkogl/ (The Code Project Open License)\n* Article at: http://www.codeproject.com/Articles/1073475/OpenGL-in-Python-with-TKinter\n\n### pyopengl\n\n* Large regions of code copied from `pyopengl/Tk/__init__.py`.\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "An opengl frame for pyopengl-tkinter based on ctype",
    "version": "0.0.4",
    "project_urls": {
        "Homepage": "http://github.com/jonwright/pyopengltk"
    },
    "split_keywords": [
        "opengl",
        "window",
        "context",
        "tk",
        "tkinter"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7e7f09782e32c071d4774321b9f8349a5e0f11258930e03a28ffb6c978cbe4b8",
                "md5": "3a14360ecefc3d7a2ab99d12ffaa4cd8",
                "sha256": "664c9c97e7f24d7664f4560064e4a4dc8a40880337483080f1b2937de052379e"
            },
            "downloads": -1,
            "filename": "pyopengltk-0.0.4-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3a14360ecefc3d7a2ab99d12ffaa4cd8",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 11978,
            "upload_time": "2022-02-21T03:44:09",
            "upload_time_iso_8601": "2022-02-21T03:44:09.417597Z",
            "url": "https://files.pythonhosted.org/packages/7e/7f/09782e32c071d4774321b9f8349a5e0f11258930e03a28ffb6c978cbe4b8/pyopengltk-0.0.4-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b90f6a7466103b044b36f5ab3784fccf7e348bd0a1670fea58ded840c03f51f4",
                "md5": "f382f39b9bd7e07e3eab4c1774922e66",
                "sha256": "4ec9bd44e5b3a8a4f3901d611b572c6d55463450ecf7d20bc51c00771b669650"
            },
            "downloads": -1,
            "filename": "pyopengltk-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "f382f39b9bd7e07e3eab4c1774922e66",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 11233,
            "upload_time": "2022-02-21T03:44:11",
            "upload_time_iso_8601": "2022-02-21T03:44:11.189858Z",
            "url": "https://files.pythonhosted.org/packages/b9/0f/6a7466103b044b36f5ab3784fccf7e348bd0a1670fea58ded840c03f51f4/pyopengltk-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-02-21 03:44:11",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jonwright",
    "github_project": "pyopengltk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pyopengltk"
}
        
Elapsed time: 0.06726s