Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yjg30737/pyqt-bounding-box
PyQt bounding box for graphic design software
https://github.com/yjg30737/pyqt-bounding-box
bounding-boxes pyqt pyqt-examples pyqt-tutorial pyqt5 pyqt5-examples pyqt5-tutorial python python3 python37 qgraphicsitem qgraphicsrectitem qgraphicsscene qgraphicsview qt
Last synced: 6 days ago
JSON representation
PyQt bounding box for graphic design software
- Host: GitHub
- URL: https://github.com/yjg30737/pyqt-bounding-box
- Owner: yjg30737
- License: mit
- Created: 2022-01-08T10:55:14.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-28T08:56:15.000Z (about 2 years ago)
- Last Synced: 2024-12-27T05:10:32.282Z (13 days ago)
- Topics: bounding-boxes, pyqt, pyqt-examples, pyqt-tutorial, pyqt5, pyqt5-examples, pyqt5-tutorial, python, python3, python37, qgraphicsitem, qgraphicsrectitem, qgraphicsscene, qgraphicsview, qt
- Language: Python
- Homepage:
- Size: 37.1 KB
- Stars: 13
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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:
```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, QGraphicsScenefrom 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 sysapp = 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
* pyqt-hbounding-box
* pyqt-vbounding-box