Skip to main content

Light and standalone python events manager.

Project description

Eventique a simple and standalone event manager for Python

Eventique is a simple and standalone event manager for Python. It is designed to be used in a standalone manner, without any dependencies on other libraries. It is designed to be simple to use and easy to understand.

Example Usage

# Create an instance of the EventsHandler
evtHandler = EventsHandler()

# Define a callback function
evtHandler.on("my_event", lambda event: print("Event triggered!"))
evtHandler.send("my_event")  # Output: Event triggered!

More complex example

import threading
import time
from eventique.EventsHandler import EventsHandler
from eventique.ThreadSharedSingleton import ThreadSharedSingleton

class MyEventsHandler(EventsHandler, metaclass=ThreadSharedSingleton):
    def __init__(self):
        super().__init__()

class MyThread(threading.Thread):
    def __init__(self):
        super().__init__()
        self.daemon = True
        self.stop = threading.Event()
        MyEventsHandler().on("stop_event", self.onStopEvent, originator=self)
        MyEventsHandler().on("print_something", self.onPrintSomething, originator=self)

    def onStopEvent(self, event):
        print("Stop Event triggered!")
        self.stop.set()

    def onPrintSomething(self, event, something):
        print(something)
    
    def run(self):
        self.stop.wait()

mt = MyThread()
mt.start()
time.sleep(2)
MyEventsHandler().send("print_something", "Something to print 1")
time.sleep(2)
MyEventsHandler().send("print_something", "Something to print 2")
time.sleep(1)
MyEventsHandler().send("stop_event")

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

eventique-1.0.1.tar.gz (5.3 kB view hashes)

Uploaded Source

Built Distribution

eventique-1.0.1-py3-none-any.whl (5.5 kB view hashes)

Uploaded Python 3

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