A lightweight event handling library for Python and C/C++.
Reason this release was yanked:
README.md had a problem
Project description
Simple Event Library (SEL)
The Simple Event Library (SEL) is a lightweight event handling library for Python >= 3.6 and C/C++. It provides a simple and efficient way to manage events and event handlers.
Current version: 1.0.4 (see res/common/ver.txt)
Installation
To install SEL, you can:
git clone https://github.com/LuoWenhaoFromDangYang/Simple-Event-Library.git
cd Simple-Event-Library
pip install .
Or:
pip install SimpleELpy==1.0.3
Usage
Python
Use SEL on Python like this:
import SimplEL as SEL
def foo(*args):
a = args[0]
b = args[1]
print(f"Received argument: {a:.2f} {b:.2f}")
return
def main():
print(f"SEL version: {SEL.SEL_PY}")
SEL.Events.add_event("foo")
SEL.Events.bind("foo", foo)
SEL.Events.trigger("foo", 0.1, 0.2)
return 0
if __name__ == "__main__":
main()
C/C++
Or use SEL on C/C++ like this:
#include <stdio.h>
#include <stdarg.h>
#include "./SEL.h"
void foo(va_list args) {
double a = va_arg(args, double);
double b = va_arg(args, double);
va_end(args);
printf("Received argument: %.2lf %.2lf\n", a, b);
return;
}
int main() {
printf("SEL version: %s\n", SEL_C);
int val;
if(val = SEL_Init()) {
printf("Failed to initialize SEL.(code %d)\n", val);
printf("Please check your RAM usage and try again.\n");
return 1;
}
printf("Successfully initialized SEL.\n");
if(val = SEL_AddEvent("foo")) {
printf("Failed to add event 'foo'.(code %d)\n", val);
printf("Please check your RAM usage and try again.\n");
return 1;
}
if(val = SEL_Bind("foo", foo)) {
printf("Failed to bind function 'foo'.(code %d)\n", val);
printf("Please check your RAM usage and try again.\n");
return 1;
}
if(val = SEL_TriggerV("foo", 0.1, 0.2)) {
printf("Failed to trigger event 'foo'.(code %d)\n", val);
printf("Please check your RAM usage and try again.\n");
return 1;
}
SEL_Free();
printf("SEL freed.\n");
return 0;
}
C++
And use SEL on C++ like this:
#include <iostream>
#include <cstdarg>
#include "./SEL.h"
void foo(va_list args) {
double a = va_arg(args, double);
double b = va_arg(args, double);
va_end(args);
std::cout << "Received argument: " << a << " " << b << std::endl;
return;
}
int main() {
std::cout << "SEL version: " << SEL_C << std::endl;
SEL::Events events;
int val;
if(val = events.Init()) {
std::cout << "Failed to initialize SEL.(code " << val << ")\n";
std::cout << "Please check your RAM usage and try again.\n";
return 1;
}
std::cout << "Successfully initialized SEL.\n";
if(val = events.AddEvent("foo")) {
std::cout << "Failed to add event 'foo'.(code " << val << ")\n";
std::cout << "Please check your RAM usage and try again.\n";
return 1;
}
if(val = events.Bind("foo", foo)) {
std::cout << "Failed to bind function 'foo'.(code " << val << ")\n";
std::cout << "Please check your RAM usage and try again.\n";
return 1;
}
if(val = events.Trigger("foo", 0.1, 0.2)) {
std::cout << "Failed to trigger event 'foo'.(code " << val << ")\n";
std::cout << "Please check your RAM usage and try again.\n";
return 1;
}
events.Free();
std::cout << "SEL freed.\n";
return 0;
}
Initialization
To initialize SEL, you can use functions like these:
- In Python, SEL initializes automatically when imported.
- In it's C/C++, you need to call
SEL_Init()manually. - In it's C++, you need to create a
SEL::Eventsobject and callevents.Init()manually. These function returns an integer value indicating the success or failure of the initialization. If the initialization is successful, the function returns 0. If the initialization fails, the function returns a non-zero value.
Compiling C/C++ programs
Compile with:
gcc -o my_program my_program.c ./res/c/main.c
Or:
g++ -o my_program my_program.cpp ./res/c/main.c
License
MIT License
Contributing
Feel free to open issues or pull requests on GitHub.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simpleelpy-1.0.4.tar.gz.
File metadata
- Download URL: simpleelpy-1.0.4.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7cb70a32e9867b16dcf41f6b29abf6b9d53399ce95e32c7f40aa6674fc53564b
|
|
| MD5 |
85c96f7c0237f148b5dd980c9360ad75
|
|
| BLAKE2b-256 |
863b6272f49caa0197c96ab50c7212eefaab6fb571ba57e6f72c9ae68996241c
|
File details
Details for the file simpleelpy-1.0.4-py3-none-any.whl.
File metadata
- Download URL: simpleelpy-1.0.4-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ef6e0d42d19764b1a15e1dcb955f2b797a58f2280a2892ca5b33ddbd7ba23da
|
|
| MD5 |
a8a490591899eddefed5c3b5739f6d84
|
|
| BLAKE2b-256 |
a6f85098dcbf61b710da1efad796b79afda1ba5cba3de95fe5a68a7317e885f4
|