pyqt-horizontal-selection-square-graphics-view
PyQt QGraphicsView with selection box. User can move vertical border of the box horizontally.
Requirements
PyQt5 >= 5.8
Setup
pip3 install git+https://github.com/yjg30737/pyqt-horizontal-selection-square-graphics-view.git --upgrade
Feature
- 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
Example
Code Sample
from PyQt5.QtWidgets import QWidget, QGridLayout, QApplication, QPushButton, QFileDialog
from pyqt_horizontal_selection_square_graphics_view.horizontalSelectionSquareGraphicsView import \
HorizontalSelectionSquareGraphicsView
class HorizontalSelectionSquareGraphicsViewExample(QWidget):
def __init__(self):
super().__init__()
self.__initUi()
def __initUi(self):
addImageBtn = QPushButton('Add image')
addImageBtn.clicked.connect(self.__addImage)
self.__view = HorizontalSelectionSquareGraphicsView()
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 = HorizontalSelectionSquareGraphicsViewExample()
ex.show()
sys.exit(app.exec_())
Result