Array label
araviq6.labels provides QLabel subclasses to display numpy array.
- class araviq6.labels.ScalableQLabel(*args: Any, **kwargs: Any)[source]
Bases:
QLabelA label which can scale the pixmap before displaying.
Pixmap can be downscaled or upscaled to fit to the label size, depending on
pixmapScaleMode().setPixmap()scales the input pixmap and update to label.originalPixmap()returns current unscaled pixmap.Notes
Do not modify the size policy and minimum size value. Changing them makes the label not shrinkable.
- class PixmapScaleMode(value)[source]
Bases:
EnumThis enum defines how the pixmap is scaled before being displayed.
- Attributes:
- PM_NoScale
Pixmap is never scaled. If the label size is smaller than the pixmap size, only a part of the pixmap is displayed.
- PM_DownScaleOnly
Pixmap is scaled, but never larger than its original size.
- PM_UpScaleOnly
Pixmap is scaled, but never smaller than its original size.
- PM_AllScale
Pixmap is scaled to any size.
- pixmapScaleMode() PixmapScaleMode[source]
Mode to scale the pixmap. Default is
PM_DownScaleOnly.
- setPixmapScaleMode(flag: PixmapScaleMode)
Set
pixmapScaleMode()to flag and update the label.
- setPixmap(pixmap: araviq6.qt_compat.QtGui.QPixmap)
Scale the pixmap and display.
- class araviq6.labels.NDArrayLabel(*args: Any, **kwargs: Any)[source]
Bases:
ScalableQLabelScalable label which can receive and display
numpy.ndarrayimage. Image array can be set bysetArray().Examples
>>> import cv2 >>> import sys >>> from araviq6 import NDArrayLabel, get_data_path >>> from araviq6.qt_compat import QtWidgets >>> img = cv2.imread(get_data_path("hello.jpg")) >>> def runGUI(): ... app = QtWidgets.QApplication(sys.argv) ... label = NDArrayLabel() ... label.setArray(cv2.cvtColor(img, cv2.COLOR_BGR2RGB)) ... label.show() ... app.exec() ... app.quit() >>> runGUI()