Image file dialog helpers

Overview

The :py:mod:.imagefile module provides helper functions for opening and saving image files using Qt dialogs and plotpy’s I/O features.

Ready-to-use open/save dialogs:

imagefile.exec_image_save_dialog()

Executes an image save dialog box (QFileDialog.getSaveFileName)

imagefile.exec_image_open_dialog()

Executes an image open dialog box (QFileDialog.getOpenFileName)

imagefile.exec_images_open_dialog()

Executes an image*s* open dialog box (QFileDialog.getOpenFileNames)

Reference

plotpy.widgets.imagefile.exec_image_save_dialog(parent: QWidget, data: ndarray, template: dict | None = None, basedir: str = '', app_name: str | None = None) str | None[source]

Executes an image save dialog box (QFileDialog.getSaveFileName)

Parameters:
  • parent – parent widget (None means no parent)

  • data – image pixel array data

  • template – image template (pydicom dataset) for DICOM files

  • basedir – base directory (’’ means current directory)

  • app_name – application name (used as a title for an eventual error message box in case something goes wrong when saving image)

Returns:

Filename if dialog is accepted, None otherwise

plotpy.widgets.imagefile.exec_image_open_dialog(parent: QWidget, basedir: str = '', app_name: str | None = None, to_grayscale: bool = True, dtype: dtype | None = None) tuple[str, ndarray] | None[source]

Executes an image open dialog box (QFileDialog.getOpenFileName)

Parameters:
  • parent – parent widget (None means no parent)

  • basedir – base directory (’’ means current directory)

  • app_name – application name (used as a title for an eventual error message box in case something goes wrong when saving image)

  • to_grayscale (bool | None) – convert image to grayscale

  • dtype – data type of the image

Returns:

(filename, data) tuple if dialog is accepted, None otherwise

plotpy.widgets.imagefile.exec_images_open_dialog(parent: QWidget, basedir: str = '', app_name: str | None = None, to_grayscale: bool = True, dtype: dtype | None = None) list[tuple[str, ndarray]] | None[source]

Executes an image*s* open dialog box (QFileDialog.getOpenFileNames)

Parameters:
  • parent – parent widget (None means no parent)

  • basedir – base directory (’’ means current directory)

  • app_name – application name (used as a title for an eventual error message box in case something goes wrong when saving image)

  • to_grayscale (bool | None) – convert image to grayscale

  • dtype – data type

Returns:

(filename, data) tuples if dialog is accepted, None otherwise