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 hashes)

Uploaded Source

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