Skip to content

Commit

Permalink
Live viewer use pathlib.Path
Browse files Browse the repository at this point in the history
  • Loading branch information
samtygier-stfc committed Sep 4, 2023
1 parent c22f4b5 commit 8991e0d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
18 changes: 9 additions & 9 deletions mantidimaging/gui/windows/live_viewer/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ class Image_Data:
Attributes
----------
image_path : str
image_path : Path
path to image file
image_name : str
name of image file
image_size : int
size of image file
image_modified_time : int
image_modified_time : float
last modified time of image file
"""

Expand Down Expand Up @@ -70,7 +70,7 @@ class LiveViewerWindowModel:
----------
presenter : LiveViewerWindowPresenter
presenter for the spectrum viewer window
path : str
path : Path
path to dataset
"""

Expand All @@ -85,15 +85,15 @@ def __init__(self, presenter: 'LiveViewerWindowPresenter'):
"""

self.presenter = presenter
self._dataset_path: str | None = None
self._dataset_path: Path | None = None
self.image_watcher: ImageWatcher | None = None

@property
def path(self) -> str | None:
def path(self) -> Path | None:
return self._dataset_path

@path.setter
def path(self, path: str) -> None:
def path(self, path: Path) -> None:
self._dataset_path = path
self.image_watcher = ImageWatcher(path)
self.image_watcher.image_changed.connect(self._handle_image_changed_in_list)
Expand Down Expand Up @@ -123,7 +123,7 @@ class ImageWatcher(QObject):
Attributes
----------
directory : str
directory : Path
path to directory to watch
watcher : QFileSystemWatcher
file system watcher to watch directory
Expand All @@ -145,13 +145,13 @@ class ImageWatcher(QObject):
"""
image_changed = pyqtSignal(list) # Signal emitted when an image is added or removed

def __init__(self, directory: str):
def __init__(self, directory: Path):
"""
Constructor for ImageWatcher class which inherits from QObject.
Parameters
----------
directory : str
directory : Path
path to directory to watch
"""

Expand Down
4 changes: 3 additions & 1 deletion mantidimaging/gui/windows/live_viewer/presenter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copyright (C) 2023 ISIS Rutherford Appleton Laboratory UKRI
# SPDX - License - Identifier: GPL-3.0-or-later
from __future__ import annotations

from pathlib import Path
from typing import TYPE_CHECKING
from logging import getLogger

Expand Down Expand Up @@ -34,7 +36,7 @@ def __init__(self, view: LiveViewerWindowView, main_window: MainWindowView):
self.main_window = main_window
self.model = LiveViewerWindowModel(self)

def set_dataset_path(self, path: str) -> None:
def set_dataset_path(self, path: Path) -> None:
"""Set the path to the dataset."""
self.model.path = path

Expand Down
2 changes: 1 addition & 1 deletion mantidimaging/gui/windows/live_viewer/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def show_most_recent_image(self, image: np.ndarray) -> None:

def watch_directory(self) -> None:
"""Show the most recent image arrived in the selected directory"""
self.presenter.set_dataset_path(str(self.path))
self.presenter.set_dataset_path(self.path)

def remove_image(self) -> None:
"""Remove the image from the view."""
Expand Down

0 comments on commit 8991e0d

Please sign in to comment.