edifice.Image

edifice.Image#

class edifice.Image(src, aspect_ratio_mode=None, **kwargs)[source]#

Bases: QtWidgetElement

An image container.

If you want to display a 3-dimensional uint8 numpy array as an image, then first convert it to a QImage using a function like this NDArray8_to_QImage.

Example:

from numpy import uint8
from numpy.typing import NDArray

def NDArray8_to_QImage(arr: NDArray[uint8]) -> QImage:
    height, width, channel = arr.shape
    return QImage(arr.data, width, height, channel * width, QImage.Format.Format_RGB888)
Parameters:
  • src (str | QImage | QPixmap) –

    One of:

  • aspect_ratio_mode (Optional[AspectRatioMode]) –

    The aspect ratio mode of the image.

    • None for a fixed image which doesn’t scale.

    • An AspectRatioMode to specify how the image should scale.

Methods

__init__(src[, aspect_ratio_mode])

register_ref(reference)

Registers provided Reference to this Element.

set_key(key)

Sets the key of the Element.

Attributes

children

The children of this Element.

props

The props of this Element.

underlying

The underlying QWidget, which may not exist if this Element has not rendered.