PyQt QGraphicsView with bounding box. User can move vertical border of the box horizontally.
PyQt5 >= 5.8
python -m pip install pyqt-hbounding-box
- Being able to drag and drop vertical border horizontally
- Pressing mouse cursor to place more adjacent border on the spot.
- Right click to release the focus of the box
- You can set the background out of the box darker with
setDarkerOutOfBox(f: bool)
.
Code Sample
from PyQt5.QtWidgets import QWidget, QGridLayout, QApplication, QPushButton, QFileDialog
from pyqt_hbounding_box.hboundingBox import HBoundingBox
class HBoundingBoxExample(QWidget):
def __init__(self):
super().__init__()
self.__initUi()
def __initUi(self):
addImageBtn = QPushButton('Add image')
addImageBtn.clicked.connect(self.__addImage)
self.__view = HBoundingBox()
lay = QGridLayout()
lay.addWidget(addImageBtn)
lay.addWidget(self.__view)
self.setLayout(lay)
def __addImage(self):
filename = QFileDialog.getOpenFileName(self, 'Open', '', 'Image Files (*.png *.jpg *.bmp)')
if filename[0]:
filename = filename[0]
self.__view.setFile(filename)
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
ex = HBoundingBoxExample()
ex.show()
sys.exit(app.exec_())
Result
example.mp4
- pyqt-vbounding-box - vertical way
- pyqt-bounding-box - horizontal/vertical ways