PyQt6-mediator-mixin


NamePyQt6-mediator-mixin JSON
Version 1.0.3 PyPI version JSON
download
home_pagehttps://github.com/Capsize-Games/PyQt6-mediator-mixin
SummaryA PyQt6 mediator mixin
upload_time2024-02-11 17:28:54
maintainer
docs_urlNone
authorCapsize LLC
requires_python>=3.10.0
licenseAGPL-3.0
keywords pyqt6 mediator mixin
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PyQt6 Mediator Mixin

[![Upload Python Package](https://github.com/Capsize-Games/PyQt6-mediator-mixin/actions/workflows/python-publish.yml/badge.svg)](https://github.com/Capsize-Games/PyQt6-mediator-mixin/actions/workflows/python-publish.yml)

![image](https://github.com/Capsize-Games/PyQt6-mediator-mixin/assets/25737761/8282b463-9cf7-46cf-836a-2efb6db30a36)

`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

```bash
pip install PyQt6-mediator-mixin
```

## Usage

```python
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

```python
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`.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Capsize-Games/PyQt6-mediator-mixin",
    "name": "PyQt6-mediator-mixin",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10.0",
    "maintainer_email": "",
    "keywords": "pyqt6,mediator,mixin",
    "author": "Capsize LLC",
    "author_email": "contact@capsizegames.com",
    "download_url": "https://files.pythonhosted.org/packages/0b/78/0ce2478e2e423475622644f6085866b48229504837be6bee64e2bd4b2ddf/PyQt6-mediator-mixin-1.0.3.tar.gz",
    "platform": null,
    "description": "# PyQt6 Mediator Mixin\n\n[![Upload Python Package](https://github.com/Capsize-Games/PyQt6-mediator-mixin/actions/workflows/python-publish.yml/badge.svg)](https://github.com/Capsize-Games/PyQt6-mediator-mixin/actions/workflows/python-publish.yml)\n\n![image](https://github.com/Capsize-Games/PyQt6-mediator-mixin/assets/25737761/8282b463-9cf7-46cf-836a-2efb6db30a36)\n\n`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.\n\nKey features:\n\n- Mediator pattern implementation for PyQt6 signals.\n- Ability to extend the `SignalCode` enum for custom signals.\n\n## Installation\n\n```bash\npip install PyQt6-mediator-mixin\n```\n\n## Usage\n\n```python\nfrom PyQt6_mediator_mixin.mediator_mixin import MediatorMixin\nfrom PyQt6_mediator_mixin.enums import SignalCode\n\nclass MyClass(MediatorMixin):\n    def __init__(self):\n        super().__init__()\n        self.register(SignalCode.MY_SIGNAL, self.my_slot_function)\n\n    def my_slot_function(self, data):\n        print(\"Received signal with data:\", data)\n\n    def some_method(self):\n        self.emit(SignalCode.MY_SIGNAL, \"some data\")\n```\n\n## Extending SignalCode Enum\n\n```python\nfrom enum import Enum\nfrom PyQt6_mediator_mixin.signal_code_factory import set_signal_code\n\nclass MySignalCode(Enum):\n    MY_SIGNAL_1 = 1\n    MY_SIGNAL_2 = 2\n\nset_signal_code(MySignalCode)\n```\n\nNow, `MyClass` can register and emit `MY_SIGNAL_1` and `MY_SIGNAL_2` using the `MediatorMixin`.\n",
    "bugtrack_url": null,
    "license": "AGPL-3.0",
    "summary": "A PyQt6 mediator mixin",
    "version": "1.0.3",
    "project_urls": {
        "Homepage": "https://github.com/Capsize-Games/PyQt6-mediator-mixin"
    },
    "split_keywords": [
        "pyqt6",
        "mediator",
        "mixin"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "35d2163fdcb17d86ba68ec6f747134bf51648338249e366a2017b69c6fd94d0f",
                "md5": "429d761deb968b8e615128fdac84d4f2",
                "sha256": "936ff9fa03d5a82a51357fa24b715bd3185249e7f08fef458e56faf457d4eafa"
            },
            "downloads": -1,
            "filename": "PyQt6_mediator_mixin-1.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "429d761deb968b8e615128fdac84d4f2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10.0",
            "size": 14234,
            "upload_time": "2024-02-11T17:28:53",
            "upload_time_iso_8601": "2024-02-11T17:28:53.234737Z",
            "url": "https://files.pythonhosted.org/packages/35/d2/163fdcb17d86ba68ec6f747134bf51648338249e366a2017b69c6fd94d0f/PyQt6_mediator_mixin-1.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0b780ce2478e2e423475622644f6085866b48229504837be6bee64e2bd4b2ddf",
                "md5": "68bb2b65b22c53076c2cb99262192805",
                "sha256": "d07d0db7b7d756a1082a679e83966efd0c4048272b658ddd9a09d0e4f4a1a940"
            },
            "downloads": -1,
            "filename": "PyQt6-mediator-mixin-1.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "68bb2b65b22c53076c2cb99262192805",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10.0",
            "size": 14253,
            "upload_time": "2024-02-11T17:28:54",
            "upload_time_iso_8601": "2024-02-11T17:28:54.824204Z",
            "url": "https://files.pythonhosted.org/packages/0b/78/0ce2478e2e423475622644f6085866b48229504837be6bee64e2bd4b2ddf/PyQt6-mediator-mixin-1.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-11 17:28:54",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Capsize-Games",
    "github_project": "PyQt6-mediator-mixin",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pyqt6-mediator-mixin"
}
        
Elapsed time: 0.18122s