pyqt-bounding-box


Namepyqt-bounding-box JSON
Version 0.0.14 PyPI version JSON
download
home_pagehttps://github.com/yjg30737/pyqt-bounding-box.git
SummaryPyQt bounding box for graphic design software
upload_time2022-12-20 11:35:38
maintainer
docs_urlNone
authorJung Gyu Yoon
requires_python
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# pyqt-bounding-box

PyQt bounding box for graphic design software



## Requirements

PyQt5 >= 5.8



## Setup

`python -m pip install pyqt-bounding-box`



## Feature

* Cursor shape changes properly for position (horizontal/vertical edge, etc.)

* Being able to resize the box horizontally/vertically/diagonally 

* Being able to move the box with either mouse cursor or arrow keys

* Being able to change the attribute of the box



## Methods Overview

* setLineWidth(self, n: int) - Default width is 3

* setColor(self, color: QColor) - Default color is black

* setStyle(self, style: Qt.PenStyle) - Default style is Qt.DashLine (You can see more about this style in <a href="https://doc.qt.io/qt-6/qt.html#PenStyle-enum">here</a>)

* setWidth(width: int)

* setHeight(height: int)

* setSize(width: int, height: int)



You can use the standard function like `setPen(pen: QPen)` if you know how to use it, Here's the example:



```python

item = BoundingBox()



pen = QPen()

pen.setStyle(Qt.DashLine)

pen.setWidth(3)

pen.setColor(QColor(0, 0, 0))



item.setPen(pen)

```



## Example

Code Sample



```python

from PyQt5.QtWidgets import QWidget, QGraphicsView, QVBoxLayout, QApplication, QGraphicsScene



from pyqt_bounding_box.boundingBox import BoundingBox





class Example(QWidget):

    def __init__(self):

        super().__init__()

        self.__initUi()



    def __initUi(self):

        view = QGraphicsView()

        self.__scene = QGraphicsScene()

        self.__scene.setSceneRect(0, 0, 400, 400)



        item = BoundingBox()

        # item.setLineWidth(8) If you want to change the edge line width, add the code.

        # item.setColor(QColor(255, 255, 255)) If you want to change the color of the line to white, add the code.

        # item.setStyle(Qt.SolidLine) If you want to change the style of line from dashed to solid line, add the code.

        self.__scene.addItem(item)

        view.setScene(self.__scene)



        lay = QVBoxLayout()

        lay.addWidget(view)



        self.setLayout(lay)





if __name__ == "__main__":

    import sys



    app = QApplication(sys.argv)

    example = Example()

    example.show()

    app.exec_()

```



Result



https://user-images.githubusercontent.com/55078043/148708740-cd1f0765-7768-44b6-88bb-770e2d34fe12.mp4



## See Also

* <a href="https://github.com/yjg30737/pyqt-hbounding-box.git">pyqt-hbounding-box</a>

* <a href="https://github.com/yjg30737/pyqt-vbounding-box.git">pyqt-vbounding-box</a>


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/yjg30737/pyqt-bounding-box.git",
    "name": "pyqt-bounding-box",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Jung Gyu Yoon",
    "author_email": "yjg30737@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/c5/7b/94bad394fa2aba207842b6eb7d6f74314a4b35b3470a9e3ebeed70cbf8ac/pyqt-bounding-box-0.0.14.tar.gz",
    "platform": null,
    "description": "\n# pyqt-bounding-box\n\nPyQt bounding box for graphic design software\n\n\n\n## Requirements\n\nPyQt5 >= 5.8\n\n\n\n## Setup\n\n`python -m pip install pyqt-bounding-box`\n\n\n\n## Feature\n\n* Cursor shape changes properly for position (horizontal/vertical edge, etc.)\n\n* Being able to resize the box horizontally/vertically/diagonally \n\n* Being able to move the box with either mouse cursor or arrow keys\n\n* Being able to change the attribute of the box\n\n\n\n## Methods Overview\n\n* setLineWidth(self, n: int) - Default width is 3\n\n* setColor(self, color: QColor) - Default color is black\n\n* setStyle(self, style: Qt.PenStyle) - Default style is Qt.DashLine (You can see more about this style in <a href=\"https://doc.qt.io/qt-6/qt.html#PenStyle-enum\">here</a>)\n\n* setWidth(width: int)\n\n* setHeight(height: int)\n\n* setSize(width: int, height: int)\n\n\n\nYou can use the standard function like `setPen(pen: QPen)` if you know how to use it, Here's the example:\n\n\n\n```python\n\nitem = BoundingBox()\n\n\n\npen = QPen()\n\npen.setStyle(Qt.DashLine)\n\npen.setWidth(3)\n\npen.setColor(QColor(0, 0, 0))\n\n\n\nitem.setPen(pen)\n\n```\n\n\n\n## Example\n\nCode Sample\n\n\n\n```python\n\nfrom PyQt5.QtWidgets import QWidget, QGraphicsView, QVBoxLayout, QApplication, QGraphicsScene\n\n\n\nfrom pyqt_bounding_box.boundingBox import BoundingBox\n\n\n\n\n\nclass Example(QWidget):\n\n    def __init__(self):\n\n        super().__init__()\n\n        self.__initUi()\n\n\n\n    def __initUi(self):\n\n        view = QGraphicsView()\n\n        self.__scene = QGraphicsScene()\n\n        self.__scene.setSceneRect(0, 0, 400, 400)\n\n\n\n        item = BoundingBox()\n\n        # item.setLineWidth(8) If you want to change the edge line width, add the code.\n\n        # item.setColor(QColor(255, 255, 255)) If you want to change the color of the line to white, add the code.\n\n        # item.setStyle(Qt.SolidLine) If you want to change the style of line from dashed to solid line, add the code.\n\n        self.__scene.addItem(item)\n\n        view.setScene(self.__scene)\n\n\n\n        lay = QVBoxLayout()\n\n        lay.addWidget(view)\n\n\n\n        self.setLayout(lay)\n\n\n\n\n\nif __name__ == \"__main__\":\n\n    import sys\n\n\n\n    app = QApplication(sys.argv)\n\n    example = Example()\n\n    example.show()\n\n    app.exec_()\n\n```\n\n\n\nResult\n\n\n\nhttps://user-images.githubusercontent.com/55078043/148708740-cd1f0765-7768-44b6-88bb-770e2d34fe12.mp4\n\n\n\n## See Also\n\n* <a href=\"https://github.com/yjg30737/pyqt-hbounding-box.git\">pyqt-hbounding-box</a>\n\n* <a href=\"https://github.com/yjg30737/pyqt-vbounding-box.git\">pyqt-vbounding-box</a>\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "PyQt bounding box for graphic design software",
    "version": "0.0.14",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "039e3971b86f9a925236b47fe5c3407d",
                "sha256": "c00bdbc84e1f0246154903141b51cf44be77de80c5beb19ec703f4b2f7f29584"
            },
            "downloads": -1,
            "filename": "pyqt_bounding_box-0.0.14-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "039e3971b86f9a925236b47fe5c3407d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 4930,
            "upload_time": "2022-12-20T11:35:36",
            "upload_time_iso_8601": "2022-12-20T11:35:36.536504Z",
            "url": "https://files.pythonhosted.org/packages/50/d8/e38d90e752ab08cf4ba2708dcbf1eb3364ff17fcecc9cecc9e3d554b500f/pyqt_bounding_box-0.0.14-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "1b6a2d15e1787c4e0b7ed2883272abb7",
                "sha256": "2650873f311bfddbde93f5f434085e2c628a32d9522f0337953e0cdb4decc45f"
            },
            "downloads": -1,
            "filename": "pyqt-bounding-box-0.0.14.tar.gz",
            "has_sig": false,
            "md5_digest": "1b6a2d15e1787c4e0b7ed2883272abb7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4281,
            "upload_time": "2022-12-20T11:35:38",
            "upload_time_iso_8601": "2022-12-20T11:35:38.232518Z",
            "url": "https://files.pythonhosted.org/packages/c5/7b/94bad394fa2aba207842b6eb7d6f74314a4b35b3470a9e3ebeed70cbf8ac/pyqt-bounding-box-0.0.14.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-20 11:35:38",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "yjg30737",
    "github_project": "pyqt-bounding-box.git",
    "lcname": "pyqt-bounding-box"
}
        
Elapsed time: 0.04483s