A PyQt6 mediator mixin
Project description
PyQt6 Mediator Mixin
PyQt6 Mediator Mixin
is a Python library that enhances PyQt6's signal-slot mechanism by implementing the mediator pattern. This pattern allows classes to emit and receive signals without knowing about each other, leading to more modular and maintainable code.
Key features:
- Mediator pattern implementation for PyQt6 signals.
- Ability to extend the
SignalCode
enum for custom signals.
Installation
pip install PyQt6_mediator_mixin
Usage
from PyQt6_mediator_mixin.mediator_mixin import MediatorMixin
from PyQt6_mediator_mixin.enums import SignalCode
class MyClass(MediatorMixin):
def __init__(self):
super().__init__()
self.register(SignalCode.MY_SIGNAL, self.my_slot_function)
def my_slot_function(self, data):
print("Received signal with data:", data)
def some_method(self):
self.emit(SignalCode.MY_SIGNAL, "some data")
Extending SignalCode Enum
from enum import Enum
from PyQt6_mediator_mixin.signal_code_factory import set_signal_code
class MySignalCode(Enum):
MY_SIGNAL_1 = 1
MY_SIGNAL_2 = 2
set_signal_code(MySignalCode)
Now, MyClass
can register and emit MY_SIGNAL_1
and MY_SIGNAL_2
using the MediatorMixin
.
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
Built Distribution
File details
Details for the file PyQt6-mediator-mixin-1.0.0.tar.gz
.
File metadata
- Download URL: PyQt6-mediator-mixin-1.0.0.tar.gz
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a48e2e75db09a7f97c674fd26fd8956266f942beade686049b26fc04ba5d6c0b |
|
MD5 | 07e1a72fc0955eb7591937807f944b47 |
|
BLAKE2b-256 | 3e8c7c073cf59a39ae40274985be457f1fd0783fa441ba13801c62913d600b41 |
File details
Details for the file PyQt6_mediator_mixin-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: PyQt6_mediator_mixin-1.0.0-py3-none-any.whl
- Upload date:
- Size: 14.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e30f17a359f1b6b39beae0f75b6c8cf577d25e3251860df96333f4be92b24204 |
|
MD5 | 444b56723c499fe6cc0efe2e191a7f2c |
|
BLAKE2b-256 | e53d1a0dd4f11d7244c754687db7e76d6875e6fab1e8e27af6c4ad25da9f367c |