Skip to main content

PyQt bounding box for graphic design software

Project description

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 here)

  • 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:

item = BoundingBox()



pen = QPen()

pen.setStyle(Qt.DashLine)

pen.setWidth(3)

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



item.setPen(pen)

Example

Code Sample

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

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

pyqt-bounding-box-0.0.14.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

pyqt_bounding_box-0.0.14-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file pyqt-bounding-box-0.0.14.tar.gz.

File metadata

  • Download URL: pyqt-bounding-box-0.0.14.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/0.0.0 CPython/3.7.6

File hashes

Hashes for pyqt-bounding-box-0.0.14.tar.gz
Algorithm Hash digest
SHA256 2650873f311bfddbde93f5f434085e2c628a32d9522f0337953e0cdb4decc45f
MD5 1b6a2d15e1787c4e0b7ed2883272abb7
BLAKE2b-256 c57b94bad394fa2aba207842b6eb7d6f74314a4b35b3470a9e3ebeed70cbf8ac

See more details on using hashes here.

File details

Details for the file pyqt_bounding_box-0.0.14-py3-none-any.whl.

File metadata

File hashes

Hashes for pyqt_bounding_box-0.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 c00bdbc84e1f0246154903141b51cf44be77de80c5beb19ec703f4b2f7f29584
MD5 039e3971b86f9a925236b47fe5c3407d
BLAKE2b-256 50d8e38d90e752ab08cf4ba2708dcbf1eb3364ff17fcecc9cecc9e3d554b500f

See more details on using hashes here.

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