playnano.gui.widgets.viewer module

The frame view of the playNano window.

class playnano.gui.widgets.viewer.ViewerWidget[source]

Bases: QWidget

Shows one RGB frame, scaled to fit, with optional time, scale bar and “RAW” label.

The frame keeps its aspect ratio and is enlarged or shrunk with Qt’s smooth (bilinear) scaling, for display only. Space around it is filled with a background colour.

display_frame(arr: ndarray)[source]

Show a new frame.

Parameters:

arr (numpy.ndarray) – RGB image, shape (height, width, 3), dtype uint8.

paintEvent(event)[source]

Draw the background, the frame and the overlays (Qt calls this).

The time is drawn at the top left, “RAW” at the top right and the scale bar, sized from the pixel size and the display scale, at the bottom left.

Parameters:

event (PySide6.QtGui.QPaintEvent) – The paint event.

resizeEvent(event: QResizeEvent)[source]

Scale the frame to the new size (Qt calls this).

Parameters:

event (PySide6.QtGui.QResizeEvent) – The resize event.

set_annotation_font(font: QFont)[source]

Set the font of the overlay text.

The font’s family is used at 18 pt.

Parameters:

font (PySide6.QtGui.QFont) – The font.

set_annotations(timestamp: float | None, draw_ts: bool, draw_scale: bool, draw_raw_label: bool, pixel_size_nm: float | None, scale_bar_nm: int | None)[source]

Set the overlays drawn on the frame.

Parameters:
  • timestamp (float or None) – Time to show, in seconds; None shows none.

  • draw_ts (bool) – Show the time.

  • draw_scale (bool) – Show the scale bar.

  • draw_raw_label (bool) – Show “RAW” at the top right.

  • pixel_size_nm (float or None) – Pixel size of the frame, in nm, used to size the scale bar.

  • scale_bar_nm (int or None) – Scale bar length, in nm.

set_background_color(rgb: tuple[int, int, int])[source]

Set the colour that fills the space around the frame.

Parameters:

rgb (tuple of int) – (R, G, B), each 0-255.

staticMetaObject = PySide6.QtCore.QMetaObject("ViewerWidget" inherits "QWidget": )