Viewers
- class pumpia.widgets.viewers.BaseViewer(tk_parent: Misc, manager: Manager, *, allow_drag_drop: bool = True, allow_drawing_rois: bool = True, allow_changing_rois: bool = True, validation_command: Callable[[ImageT], bool] | None = None, preload_command: Callable[[Self, ImageT], ImageT] | None = None)
Base class for viewers. Do not use directly.
Method can_show_image must be overwritten by the user when subclassing BaseViewer. image_type class attribute should also be set to the expected image type, default is BaseImageSet.
If allowed the user can drag and drop a valid image from a Manager treeview into the viewer to load it.
The following shortcuts are provided for user interaction:
Mouse wheel: Scroll through image slices.
Control + Mouse wheel: Zoom in/out.
Mouse wheel button + drag: Adjust window/level.
Control + R: Reset image viewing parameters.
- Parameters:
tk_parent (tk.Misc) – The parent widget.
manager (Manager) – The manager object.
allow_drag_drop (bool, optional) – Whether to allow drag and drop of images into the viewer(default is True).
allow_drawing_rois (bool, optional) – Whether to allow drawing ROIs on the viewer (default is True).
validation_command (Callable[[ImageT], bool], optional) – The validation command ran when an image is loaded, if validation fails then image is not shown. Must accept an image of the type viewable by the viewer (default is None).
preload_command (Callable[[Self, ImageT], ImageT], optional) – The preload command to process a loaded image before it is shown. Must accept and return an image of the type viewable by the viewer(default is None).
- allow_drag_drop
Whether to allow drag and drop of images into the viewer.
- Type:
bool
- allow_drawing_rois
Whether to allow drawing ROIs on the viewer.
- Type:
bool
- validation_command
The validation command ran when an image is loaded.
- Type:
Callable[[ImageT], bool] or None
- preload_command
The preload command to process a loaded image before it is shown.
- Type:
Callable[[Self, ImageT], ImageT] or None
- mouse_x
The x-coordinate of the last mouse event.
- Type:
float
- mouse_y
The y-coordinate of the last mouse event.
- Type:
float
- last_event_time
The time of the last event.
- Type:
int
- current_slice
The current slice number of the image.
- Type:
int
- manual_override
Whether manual ROI drawing is active.
- Type:
bool
- image
The current image showing on the Viewer.
- Type:
T or None
- pil_image
The PIL image object.
- Type:
Image.Image
- pil_tkimage
The PIL image object as a Tkinter PhotoImage.
- Type:
ImageTk.PhotoImage
- zoom_factor
- Type:
float
- current_image
- Type:
T or None
- add_load_trace(func: Callable[[], Any])
Adds a load trace function. This function is called when an image is loaded.
- remove_load_trace(func: Callable[[], Any])
Removes a load trace function.
- can_show_image(cls, image: T) bool
Checks if the viewer can show the image.
- unload_images()
Unloads the images from the viewer.
- load_image(image: T)
Loads an image into the viewer.
- viewer_to_image_pos(position: Position) Position
Converts viewer coordinates to image coordinates.
- image_to_viewer_pos(position: Position) Position
Converts image coordinates to viewer coordinates.
- update()
Updates the viewer.
- reset_image()
Resets the image to its original state.
- manual_roi_draw(roi: ManualROIType, name: str | None = None, replace: bool = True, cache: bool = True, roi_colour: str = ROI_COLOUR, active_colour: str = ACTIVE_ROI_COLOUR)
Starts manual ROI drawing.
- stop_manual_roi_draw()
Stops manual ROI drawing.
- change_slice(amount: int = 1)
Changes the current slice of the image by amount of slices.
- set_slice(slice_num: int)
Sets the current slice of the image.
- change_zoom(amount: float = 1)
Changes the zoom level of the image.
- window_level(window_delta: float, level_delta: float)
Adjusts the window and level of the image.
- set_window_level(window: float, level: float)
Sets the window and level of the image.
- move_image(delta_x: float, delta_y: float)
Moves the image on the viewer based on the given deltas.
- set_image_loc(x: float, y: float)
Sets the image location on the viewer.
- class pumpia.widgets.viewers.Viewer(tk_parent: Misc, manager: Manager, *, allow_drag_drop: bool = True, allow_drawing_rois: bool = True, allow_changing_rois: bool = True, validation_command: Callable[[ImageT], bool] | None = None, preload_command: Callable[[Self, ImageT], ImageT] | None = None)
Viewer for displaying all images.
- class pumpia.widgets.viewers.ArrayViewer(tk_parent: Misc, manager: Manager, *, allow_drag_drop: bool = True, allow_drawing_rois: bool = True, allow_changing_rois: bool = True, validation_command: Callable[[ImageT], bool] | None = None, preload_command: Callable[[Self, ImageT], ImageT] | None = None)
Viewer for displaying ArrayImage images.
- class pumpia.widgets.viewers.MonochromeViewer(tk_parent: Misc, manager: Manager, *, allow_drag_drop: bool = True, allow_drawing_rois: bool = True, allow_changing_rois: bool = True, validation_command: Callable[[ImageT], bool] | None = None, preload_command: Callable[[Self, ImageT], ImageT] | None = None)
Viewer for displaying monochrome ArrayImage images (i.e. not RGB or multisample).
- class pumpia.widgets.viewers.DicomViewer(tk_parent: Misc, manager: Manager, *, allow_drag_drop: bool = True, allow_drawing_rois: bool = True, allow_changing_rois: bool = True, validation_command: Callable[[ImageT], bool] | None = None, preload_command: Callable[[Self, ImageT], ImageT] | None = None)
Viewer for displaying DICOM Series or Instance images.
- class pumpia.widgets.viewers.MonochromeDicomViewer(tk_parent: Misc, manager: Manager, *, allow_drag_drop: bool = True, allow_drawing_rois: bool = True, allow_changing_rois: bool = True, validation_command: Callable[[ImageT], bool] | None = None, preload_command: Callable[[Self, ImageT], ImageT] | None = None)
Viewer for displaying monochrome DICOM Series or Instance images (i.e. not RGB or multisample).