Skip to main content

Galaxie EveLoop is a low tech EventLoop, it contain minimalistic Bus and Loop

Project description

License: WTFPL Documentation Status

Galaxie EveLoop documentation

https://galaxie-curses.readthedocs.io/_images/logo_galaxie.png

Description

Galaxie Event Loop is a low tech main loop couple with a event bus.

After many years as kernel of Galaxie Curses project, it have been as decision to extract the main loop and the event bus. Especially that because it work and be very small.

Installation via pip

Pypi

pip install galaxie-eveloop

Pypi Test

pip install -i https://test.pypi.org/simple/ galaxie-eveloop

Example

from glxeveloop import MainLoop
from time import time

count = 1
mainloop = MainLoop().loop
mainloop.timer.fps.min = 30
mainloop.timer.fps.value = 60
mainloop.timer.fps.max = 30
start = time()


def pre():
    global count
    global mainloop
    global start
    if count >= 30:
        mainloop.stop()


def cmd():
    global count
    global mainloop

    print("COUNT: {0}, FPS: {1}".format(count, mainloop.timer.fps.value))


def post():
    global count
    count += 1
    if count > 30:
        print("TIME: {0}".format((time() - start)))
        print("PRECISION: {0}".format(1 - (time() - start)))


def main():
    mainloop.hooks.cmd = cmd
    mainloop.hooks.pre = pre
    mainloop.hooks.post = post

    mainloop.start()


if __name__ == '__main__':
    main()

While return

COUNT: 1, FPS: 60.0
COUNT: 2, FPS: 60.0
COUNT: 3, FPS: 30.0
COUNT: 4, FPS: 30.0
COUNT: 5, FPS: 30.0
COUNT: 6, FPS: 30.0
COUNT: 7, FPS: 30.0
COUNT: 8, FPS: 30.0
COUNT: 9, FPS: 30.0
COUNT: 10, FPS: 30.0
COUNT: 11, FPS: 30.0
COUNT: 12, FPS: 30.0
COUNT: 13, FPS: 30.0
COUNT: 14, FPS: 30.0
COUNT: 15, FPS: 30.0
COUNT: 16, FPS: 30.0
COUNT: 17, FPS: 30.0
COUNT: 18, FPS: 30.0
COUNT: 19, FPS: 30.0
COUNT: 20, FPS: 30.0
COUNT: 21, FPS: 30.0
COUNT: 22, FPS: 30.0
COUNT: 23, FPS: 30.0
COUNT: 24, FPS: 30.0
COUNT: 25, FPS: 30.0
COUNT: 26, FPS: 30.0
COUNT: 27, FPS: 30.0
COUNT: 28, FPS: 30.0
COUNT: 29, FPS: 30.0
COUNT: 30, FPS: 30.0
TIME: 0.9341855049133301
PRECISION: 0.0657961368560791

It Take 2 iterations for the loop to slow FPS for match the 30 FPS ask by the setting. The mainloop can impose a Frame Rate :)

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

galaxie_eveloop-0.1.5.tar.gz (16.4 kB view details)

Uploaded Source

File details

Details for the file galaxie_eveloop-0.1.5.tar.gz.

File metadata

  • Download URL: galaxie_eveloop-0.1.5.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.2

File hashes

Hashes for galaxie_eveloop-0.1.5.tar.gz
Algorithm Hash digest
SHA256 44bb1c7181b78ffd5efa18216e62bed94d38efc0434eb5277b8e81a574dff56d
MD5 f95bfc9045c5f9bc59f6c4792b33f9cd
BLAKE2b-256 21df9233a3b428f20cbf5684521a8dfeb518240e3141d6532a5263f584f7d076

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