pyqt-vbounding-box

PyQt QGraphicsView with bounding box. User can move horizontal border of the box vertically.


Keywords
pyqt, pyqt-examples, pyqt-tutorial, pyqt5, pyqt5-examples, python, python3, python37, qgraphicsitem, qgraphicsscene, qgraphicsview, qpen, qt, selection-box
License
MIT
Install
pip install pyqt-vbounding-box==0.0.11

Documentation

pyqt-vbounding-box

PyQt QGraphicsView with bounding box. User can move horizontal border of the box vertically.

Requirements

  • PyQt5 >= 5.8

Setup

python -m pip install pyqt-vbounding-box

Feature

  • Being able to drag and drop horizontal border vertically
  • Pressing mouse cursor to place more adjacent border on the spot.
  • Right click to release the focus of the box

Example

Code Sample

from PyQt5.QtWidgets import QWidget, QGridLayout, QApplication, QPushButton, QFileDialog

from pyqt_vbounding_box.vBoundingBox import VBoundingBox


class VBoundingBoxExample(QWidget):
    def __init__(self):
        super().__init__()
        self.__initUi()

    def __initUi(self):
        addImageBtn = QPushButton('Add image')
        addImageBtn.clicked.connect(self.__addImage)
        self.__view = VBoundingBox()

        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 = VBoundingBoxExample()
    ex.show()
    sys.exit(app.exec_())

Result

pyqt_vertical_selection_square_graphics_view_example.mp4

See Also