widgets#

Provides an image viewer widget for a Qt application.

class ImageViewer(parent: QWidget = None)[source]#

Qt widget that displays a zoom-level image pyramid.

Drag while keeping the left mouse button pressed. Zoom in with the + key, zoom out with -. Or use the mouse wheel or pinch gesture on the track pad.

sizeHint()[source]#

Tells Qt the initial size of the widget.

load(file: Path | None, zoom: int = 0)[source]#

Displays the image loaded from the given file.

file is a Path object pointing to an image file. Currently, only DeepZoom images (.dzi) are supported.

zoom specifies the initial zoom level, with 0 being most zoomed out and greater numbers being zoomed in. There is no way to determine the maximum zoom other than querying the image.

zoom_in()[source]#

Zooms in by one level, towards the position of the mouse.

zoom_out()[source]#

Zooms out by one level, relative to the mouse position.

zoom_by(levels: int)[source]#

Zooms in or out by the given number of levels.

Zooms in if levels is positive, out if negative.

zoom_to(level: int)[source]#

Zooms to the given zoom level.

move_by(Δx: int, Δy: int)[source]#

Moves viewport by (Δx, Δy) pixels.

redraw()[source]#

Redraws the widget.

mousePressEvent(event: QEvent)[source]#

Called when the user pressed a mouse button.

mouseReleaseEvent(event: QEvent)[source]#

Called when the user released a mouse button.

mouseDoubleClickEvent(event: QEvent)[source]#

Called when the user double-clicked with the mouse.

mouseMoveEvent(event: QEvent)[source]#

Called when the user moved the mouse.

wheelEvent(event: QEvent)[source]#

Called when the user turned the mouse wheel.

resizeEvent(event: QEvent)[source]#

Called when the widget’s size changed.