Skip to main content

The SmartSignal lib is an event driven system similar to QT.

Project description

Smart Signals

Build codecov PyPi version License: MIT

This is a small lib for the signal-slot-pattern. This corresponds to a modification of the observer pattern. It originally comes from QT.

The input types are checked to ensure that they also correspond to the definition. The default python data types (str, int, float, list) and also the typing data types (List[str], Dict[str, int]) are supported. In addition, the log can be used to track which signal called which slot for error diagnosis.

Install

You can install this package with pip tool from https://pypi.org/.

pip install SmartSignals

Usage

import logging

from smart_signals import SmartSignal, SmartSignalSlot

logging.basicConfig(level=logging.DEBUG, format="%(asctime)s | %(levelname)-10.10s | %(name)-30.30s | %(message)s")


class Test:
    @SmartSignalSlot(str)
    def slot(self, message: str):
        print(message)
        pass


test = Test()
signal = SmartSignal(str)
signal.connect(test.slot)
signal.emit("message")

Log output

2022-06-07 21:16:52 | DEBUG      | SmartSignal                    | emit signal from: .\PySignals\smart_signals_tests\test_smart_signals.py:test_py_signal_check_emit_type_string:145 to slot <function TestPySignal.test_py_signal_check_emit_type_string.<locals>.signal_slot_with_typ_list_of_string at 0x000001B9259A6F70>

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

SmartSignals-0.2.0.tar.gz (5.0 kB view hashes)

Uploaded Source

Built Distribution

SmartSignals-0.2.0-py3-none-any.whl (5.1 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