PyQt bounding box for graphic design software
MIT License
PyQt bounding box for graphic design software
PyQt5 >= 5.8
python -m pip install pyqt-bounding-box
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)
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