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.0.tar.gz (103.7 kB view details)

Uploaded Source

Built Distributions

pyprojector-1.0.0-cp37-cp37m-win_amd64.whl (31.5 kB view details)

Uploaded CPython 3.7m Windows x86-64

pyprojector-1.0.0-cp37-cp37m-win32.whl (29.5 kB view details)

Uploaded CPython 3.7m Windows x86

pyprojector-1.0.0-cp36-cp36m-win_amd64.whl (31.5 kB view details)

Uploaded CPython 3.6m Windows x86-64

pyprojector-1.0.0-cp36-cp36m-win32.whl (29.5 kB view details)

Uploaded CPython 3.6m Windows x86

File details

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

File metadata

  • Download URL: pyprojector-1.0.0.tar.gz
  • Upload date:
  • Size: 103.7 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.1 CPython/3.7.3

File hashes

Hashes for pyprojector-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e2183e3cdeeaf1e401b8010b432954cb09da4a9c45119b3ce89e41986b49f3ea
MD5 c60078b7b103cd10fcdaca88c6032756
BLAKE2b-256 075fd68a740fc0bbc7e92b3ce0d2b2053de301242720056a0d357512700bb59c

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: pyprojector-1.0.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 31.5 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.1 CPython/3.7.3

File hashes

Hashes for pyprojector-1.0.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 4913869b115c70a454328c8e640405c57310aa913aedd274fa92fa15c7e287aa
MD5 a6a3d8f71dcf84a15d928c1d0ef16618
BLAKE2b-256 ab085512e8e81f05548b86dbf972ca0af88914ea54e3d5cf54aacdbb19384e0c

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: pyprojector-1.0.0-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 29.5 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.1 CPython/3.7.3

File hashes

Hashes for pyprojector-1.0.0-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 39146bb7e951f80813a0369ef79fd4b72c25e7a7d280403bcb2c5ce5194a3775
MD5 a2c5a6b1a6caffe62681eff743a4c9eb
BLAKE2b-256 fe80b398c1b254a3e9b9ff69afb8de7b55e9b3ecb9dc96ddf97c2b45a1742065

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: pyprojector-1.0.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 31.5 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.1 CPython/3.7.3

File hashes

Hashes for pyprojector-1.0.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 f84371d78b97fe0ca9a18717413c82df1b984a1eac15b0fedc54fb9c01c310ac
MD5 c85d01ba07880933d02b16ea3b0de7f0
BLAKE2b-256 25e48c2b2d640ca696336807772827d5c3e57692cb8641e445f81af139982ad7

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: pyprojector-1.0.0-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 29.5 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.1 CPython/3.7.3

File hashes

Hashes for pyprojector-1.0.0-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 21a49f2767ff142bce559f3bcfabcd3dcae3c69be99d8543dc8a71c360d6e934
MD5 9e3af752d7bb8eb81c8324ba86cd5d6a
BLAKE2b-256 51101d903d6d4e281ef74de68eb189a7ccbf45710cdc1d7cb8cd96eeda934517

See more details on using hashes here.

Provenance

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