Skip to main content

pyprojector is an asyncronous window for rendering

Project description

pyprojector

pyprojector is a Python 3 module that creates an interpreter independent window. Tight loops, long calculation often prevents us from updating a window, using Python threads adds more complexity and a choppy rendering experience.

How pyprojector works?

A window is created on a new OS thread, the WinAPI takes care of the window. The window has two OpenGL contexts with shared objects. The user can use the the OpenGL context assigned to the current thread to render arbitrary images using OpenGL. The window.update(framebuffer=...) method takes a framebuffer and copies its content into a backbuffer. The backbuffer will be used anytime the window needs a redraw.

Features

  • The user can create and update a window with a minimal API.
  • The rendered frames are quickly copied to a backbuffer maintained by another thread.
  • The user can render depending on the window's visibility.
  • A hidden window have an almost zero performance penalty.
  • The user is not responsible updating a window to avoid dirty frames.
  • The window can be shown/hidden from the system tray.
  • Closing the window just hides the window.
  • A screenshot can be saved with ctrl+s.
  • A ctrl+c in the window raises a KeyboardInterrupt.
  • A screenshot can be taken programatically using window.screenshot().
  • The program can be halted with ctrl+shift+q.
  • The window is refreshed only when necessary.
  • There is a builtin FPS limiter.

Example

import pyprojector

wnd = pyprojector.window((840, 480), __file__, fps=60)
fbo = ... # OpenGL Framebuffer Object

while True:
    # the user's loop
    # do long calculation, train AI, run gyms, ...

    if wnd.visible:
        # render into fbo
        # pass fbo to the window
        wnd.update(fbo)

for more examples please visit the examples.

Acknowledgement

This project is using miniz to save PNG files.

Project details


Download files

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

Source Distribution

pyprojector-1.0.1.tar.gz (104.0 kB view details)

Uploaded Source

Built Distributions

pyprojector-1.0.1-cp37-cp37m-win_amd64.whl (30.6 kB view details)

Uploaded CPython 3.7m Windows x86-64

pyprojector-1.0.1-cp37-cp37m-win32.whl (28.9 kB view details)

Uploaded CPython 3.7m Windows x86

pyprojector-1.0.1-cp36-cp36m-win_amd64.whl (30.6 kB view details)

Uploaded CPython 3.6m Windows x86-64

pyprojector-1.0.1-cp36-cp36m-win32.whl (28.9 kB view details)

Uploaded CPython 3.6m Windows x86

File details

Details for the file pyprojector-1.0.1.tar.gz.

File metadata

  • Download URL: pyprojector-1.0.1.tar.gz
  • Upload date:
  • Size: 104.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4

File hashes

Hashes for pyprojector-1.0.1.tar.gz
Algorithm Hash digest
SHA256 154b2d764d32f2a4c848e878584144b5037eba310f10fbaa4a4ef3bbacfc2bd1
MD5 925a99fcc6b95311c5ee6dca66caae34
BLAKE2b-256 29bc7d35d82be9e3fe53bb1cc7ebf75224be7e7eff42b3440be04657161ca08a

See more details on using hashes here.

File details

Details for the file pyprojector-1.0.1-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: pyprojector-1.0.1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 30.6 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4

File hashes

Hashes for pyprojector-1.0.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 ecd1b05262d8201cb54b31ee6cca30e441e4789efc87dcf23e7a6a548683fbfd
MD5 84eb59cdd912fdccafea37a49abc6677
BLAKE2b-256 b113fee169b59f72ca16c6d638de737882dc05d8ecc44c277099726694eac9fe

See more details on using hashes here.

File details

Details for the file pyprojector-1.0.1-cp37-cp37m-win32.whl.

File metadata

  • Download URL: pyprojector-1.0.1-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 28.9 kB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4

File hashes

Hashes for pyprojector-1.0.1-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 ee2c0dda3c0bc8ad521671643e242d7e4f0ba34d807734949dff17df4b7bd18e
MD5 4dd15cf7c3a45a402a8ae1b10d091c85
BLAKE2b-256 a0d011d23293b25aabd761b3e722ba38d232555759842185938126d12ced17e0

See more details on using hashes here.

File details

Details for the file pyprojector-1.0.1-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: pyprojector-1.0.1-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 30.6 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4

File hashes

Hashes for pyprojector-1.0.1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 00c336cac3b96c819938a236eb57f664faa11b7e26db9a012a08456074b86b03
MD5 9f2d578f18673c8b4bbf96c69a5f008d
BLAKE2b-256 470099153ba0f99c8d5cf744a5948082057ea49ee04ae9a40188e3a376efb73c

See more details on using hashes here.

File details

Details for the file pyprojector-1.0.1-cp36-cp36m-win32.whl.

File metadata

  • Download URL: pyprojector-1.0.1-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 28.9 kB
  • Tags: CPython 3.6m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4

File hashes

Hashes for pyprojector-1.0.1-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 f71b982ab4998f8f7142ff8b2ed6c04b31126a4be0021b11412bb7ea61bd6b79
MD5 8775827f3d06b5dd4b3a37882e528a39
BLAKE2b-256 1ff7bba560b2610805300b5f7ba297df2cb4260acfe8078c12fdaae7144a829c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page