Skip to main content

Use event handler simply.

Project description

pyeventlib

pyeventlib library is used to handle event in a simple way.

Install

pip install pyeventlib

Examples

import asyncio
from pyeventlib import *


class CloseEventArgs(EventArgs):
    def __init__(self):
        self.accept = False
# other option
# CloseEventArgs = EventArgs.create(
#     "CloseEventArgs", 
#     {"accept": False})


event1 = EventHandler()
event2 = EventHandler()


async def main():
    await event1(__name__)
    args = CloseEventArgs()
    await event2(__name__, args)
    print(args.accept)  # True
    

@event1.register
def event_a(sender):
    print("Event A Sender: " + sender)


async def event_b(sender):
    print("Event C Sender: " + sender)
event1 += event_b


@event2.register
def close_event(sender, e):
    e.accept = True


asyncio.run(main())

Copyright

Copyright 2023. DuelitDev all rights reserved.

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

pyeventlib-1.1.1-py3-none-any.whl (4.2 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