pywidgets-ext


Namepywidgets-ext JSON
Version 0.1.5 PyPI version JSON
download
home_pagehttps://pypi.org/project/pywidgets-ext/
Summary
upload_time2023-09-21 08:41:06
maintainer
docs_urlNone
authorLeo
requires_python>=3.9,<3.12
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pywidgets-ext

This is a custom widget module for `PySide6` that makes it easy to manage and use during development.

## Installation

Install using pip:

```bash
pip install pywidgets-ext
```

Install using poetry (recommended):

```bash
poetry add pywidgets-ext
```

## Usage

```python
from pywidgets_ext import *
```

## Modules

### PyFigureCanvas

`PyFigureCanvas` is a custom widget inheriting from `FigureCanvasQTAgg`. It's designed to display matplotlib charts. A unique feature is its magnified preview when the mouse hovers over it, which hides when the mouse leaves. The magnified view adjusts according to the screen size and mouse position. Additionally, `PyFigureCanvas` offers methods to get chart dimensions, calculate data ratio, and adjust graphics view size on resize.

To see it in action:

```python
python -m pywidgets_ext.PyFigureCanvas
```

![PyFigureCanvas](https://raw.githubusercontent.com/leoli0605/pywidgets-ext/main/docs/images/py_figure_canvas.webp)

Sample code:

```python
import matplotlib.pyplot as plt
from PySide6.QtWidgets import QMainWindow, QApplication
from pywidgets_ext import PyFigureCanvas


class MainWindow(QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        fig, ax = self.create_sample_plot()
        self.canvas = PyFigureCanvas(fig)
        self.setup_main_window()

    def create_sample_plot(self):
        fig, ax = plt.subplots(figsize=(5, 5))
        ax.plot([0, 1, 2, 3, 4], [0, 1, 4, 9, 16], label="y = x^2")
        ax.set_title("Sample Plot")
        ax.set_xlabel("x")
        ax.set_ylabel("y")
        ax.legend()
        return fig, ax

    def setup_main_window(self):
        self.setCentralWidget(self.canvas)
        self.setWindowTitle("PyFigureCanvas Demo")
        self.resize(600, 600)


if __name__ == "__main__":
    app = QApplication([])
    window = MainWindow()
    window.show()
    app.exec()
```

### PyGraphicsView

`PyGraphicsView` is a view class inheriting from `QGraphicsView`. It lets users click and drag in the scene to draw and adjust resizable rectangular regions (`ResizableRect`). It offers specific drawing and optimization options for better performance and visuals. Users can select rectangles and delete them using the `Delete` key. Also, it auto-adjusts rectangles when the scene size changes.

To see it in action:

```python
python -m pywidgets_ext.PyGraphicsView
```

![PyGraphicsView](https://raw.githubusercontent.com/leoli0605/pywidgets-ext/main/docs/images/py_graphics_view.webp)

Sample code:

```python
from PySide6.QtCore import Qt, QRectF, QPointF
from PySide6.QtWidgets import QApplication, QMainWindow
from pywidgets_ext import PyGraphicsView


class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.view = PyGraphicsView()
        self.view.setSceneRect(0, 0, 500, 500)
        self.setCentralWidget(self.view)
        self.setGeometry(100, 100, 800, 600)
        self.setWindowTitle("PyGraphicsView Example")


if __name__ == "__main__":
    app = QApplication([])
    window = MainWindow()
    window.show()
    app.exec()
```

## Contributions

Contributions of any kind are welcome! Make sure to read the [Contribution Guide](https://github.com/leoli0605/pywidgets-ext/blob/main/CONTRIBUTING.md) first.

## License

This project is under the [MIT License](https://github.com/leoli0605/pywidgets-ext/blob/main/LICENSE).

## Author

- Leo - [Github](https://github.com/leoli0605)

            

Raw data

            {
    "_id": null,
    "home_page": "https://pypi.org/project/pywidgets-ext/",
    "name": "pywidgets-ext",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<3.12",
    "maintainer_email": "",
    "keywords": "",
    "author": "Leo",
    "author_email": "jafee201153@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/b7/a9/6ea1310ddbe4e9497b286ba7a53b2edc4d473a7b706d680a74227d6137cf/pywidgets_ext-0.1.5.tar.gz",
    "platform": null,
    "description": "# pywidgets-ext\n\nThis is a custom widget module for `PySide6` that makes it easy to manage and use during development.\n\n## Installation\n\nInstall using pip:\n\n```bash\npip install pywidgets-ext\n```\n\nInstall using poetry (recommended):\n\n```bash\npoetry add pywidgets-ext\n```\n\n## Usage\n\n```python\nfrom pywidgets_ext import *\n```\n\n## Modules\n\n### PyFigureCanvas\n\n`PyFigureCanvas` is a custom widget inheriting from `FigureCanvasQTAgg`. It's designed to display matplotlib charts. A unique feature is its magnified preview when the mouse hovers over it, which hides when the mouse leaves. The magnified view adjusts according to the screen size and mouse position. Additionally, `PyFigureCanvas` offers methods to get chart dimensions, calculate data ratio, and adjust graphics view size on resize.\n\nTo see it in action:\n\n```python\npython -m pywidgets_ext.PyFigureCanvas\n```\n\n![PyFigureCanvas](https://raw.githubusercontent.com/leoli0605/pywidgets-ext/main/docs/images/py_figure_canvas.webp)\n\nSample code:\n\n```python\nimport matplotlib.pyplot as plt\nfrom PySide6.QtWidgets import QMainWindow, QApplication\nfrom pywidgets_ext import PyFigureCanvas\n\n\nclass MainWindow(QMainWindow):\n    def __init__(self):\n        super(MainWindow, self).__init__()\n        fig, ax = self.create_sample_plot()\n        self.canvas = PyFigureCanvas(fig)\n        self.setup_main_window()\n\n    def create_sample_plot(self):\n        fig, ax = plt.subplots(figsize=(5, 5))\n        ax.plot([0, 1, 2, 3, 4], [0, 1, 4, 9, 16], label=\"y = x^2\")\n        ax.set_title(\"Sample Plot\")\n        ax.set_xlabel(\"x\")\n        ax.set_ylabel(\"y\")\n        ax.legend()\n        return fig, ax\n\n    def setup_main_window(self):\n        self.setCentralWidget(self.canvas)\n        self.setWindowTitle(\"PyFigureCanvas Demo\")\n        self.resize(600, 600)\n\n\nif __name__ == \"__main__\":\n    app = QApplication([])\n    window = MainWindow()\n    window.show()\n    app.exec()\n```\n\n### PyGraphicsView\n\n`PyGraphicsView` is a view class inheriting from `QGraphicsView`. It lets users click and drag in the scene to draw and adjust resizable rectangular regions (`ResizableRect`). It offers specific drawing and optimization options for better performance and visuals. Users can select rectangles and delete them using the `Delete` key. Also, it auto-adjusts rectangles when the scene size changes.\n\nTo see it in action:\n\n```python\npython -m pywidgets_ext.PyGraphicsView\n```\n\n![PyGraphicsView](https://raw.githubusercontent.com/leoli0605/pywidgets-ext/main/docs/images/py_graphics_view.webp)\n\nSample code:\n\n```python\nfrom PySide6.QtCore import Qt, QRectF, QPointF\nfrom PySide6.QtWidgets import QApplication, QMainWindow\nfrom pywidgets_ext import PyGraphicsView\n\n\nclass MainWindow(QMainWindow):\n    def __init__(self):\n        super().__init__()\n        self.view = PyGraphicsView()\n        self.view.setSceneRect(0, 0, 500, 500)\n        self.setCentralWidget(self.view)\n        self.setGeometry(100, 100, 800, 600)\n        self.setWindowTitle(\"PyGraphicsView Example\")\n\n\nif __name__ == \"__main__\":\n    app = QApplication([])\n    window = MainWindow()\n    window.show()\n    app.exec()\n```\n\n## Contributions\n\nContributions of any kind are welcome! Make sure to read the [Contribution Guide](https://github.com/leoli0605/pywidgets-ext/blob/main/CONTRIBUTING.md) first.\n\n## License\n\nThis project is under the [MIT License](https://github.com/leoli0605/pywidgets-ext/blob/main/LICENSE).\n\n## Author\n\n- Leo - [Github](https://github.com/leoli0605)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "",
    "version": "0.1.5",
    "project_urls": {
        "Homepage": "https://pypi.org/project/pywidgets-ext/",
        "Repository": "https://github.com/leoli0605/pywidgets-ext"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bcdddcfbf64df7070dfec4de9ccdc1982b49c544dffcbf3fe299e6e5fdde7b4c",
                "md5": "73abcc19158e4a2c2d29f6c47fcb97c0",
                "sha256": "5b183ccb7c003ff5353df6bc69de66e5ccca6d10cb6114a36990dd798892f0e3"
            },
            "downloads": -1,
            "filename": "pywidgets_ext-0.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "73abcc19158e4a2c2d29f6c47fcb97c0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<3.12",
            "size": 8007,
            "upload_time": "2023-09-21T08:41:04",
            "upload_time_iso_8601": "2023-09-21T08:41:04.932578Z",
            "url": "https://files.pythonhosted.org/packages/bc/dd/dcfbf64df7070dfec4de9ccdc1982b49c544dffcbf3fe299e6e5fdde7b4c/pywidgets_ext-0.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b7a96ea1310ddbe4e9497b286ba7a53b2edc4d473a7b706d680a74227d6137cf",
                "md5": "40242fbfdff5c27caa9338f0807fb69a",
                "sha256": "0349cafe84fc2743def2e241cb01f3136b1e7b7807af04ad2d7c0c795a0cf490"
            },
            "downloads": -1,
            "filename": "pywidgets_ext-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "40242fbfdff5c27caa9338f0807fb69a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<3.12",
            "size": 6515,
            "upload_time": "2023-09-21T08:41:06",
            "upload_time_iso_8601": "2023-09-21T08:41:06.920020Z",
            "url": "https://files.pythonhosted.org/packages/b7/a9/6ea1310ddbe4e9497b286ba7a53b2edc4d473a7b706d680a74227d6137cf/pywidgets_ext-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-21 08:41:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "leoli0605",
    "github_project": "pywidgets-ext",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pywidgets-ext"
}
        
Leo
Elapsed time: 0.44153s