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
Release history Release notifications | RSS feed
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 details)
Built Distribution
File details
Details for the file eventique-1.0.1.tar.gz
.
File metadata
- Download URL: eventique-1.0.1.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b26b515b2877c50ee58302f94ab93f655fe96dc168b6876179fd84721c764416 |
|
MD5 | 84822dda95761a875527eb4205eb8c39 |
|
BLAKE2b-256 | 9124f02876be74f952b5bc58de465c931e5c5239e4cc244386317693c195f30a |
File details
Details for the file eventique-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: eventique-1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4a27e29d0e67551d95158ea9b46d8282b178847e634c17460e1909db02c23be |
|
MD5 | 20e938ddf8742fbae6abda106cd907d8 |
|
BLAKE2b-256 | 871403174a1455383545149938936ed1f8f933a13eaad3139418b049bb290bea |