Skip to content

Commit

Permalink
Correct type annotations in the MainWindow, and related classes (#2243)
Browse files Browse the repository at this point in the history
  • Loading branch information
samtygier-stfc authored Jul 10, 2024
2 parents abfb1ea + 021714c commit bdf37e9
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 71 deletions.
2 changes: 1 addition & 1 deletion mantidimaging/gui/windows/main/image_save_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __init__(self, parent, stack_list):

self.selected_stack = None

def save_all(self):
def save_all(self) -> None:
self.selected_stack = self.stack_uuids[self.stackNames.currentIndex()]
self.parent().execute_image_file_save()

Expand Down
10 changes: 5 additions & 5 deletions mantidimaging/gui/windows/main/nexus_save_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

from PyQt5.QtWidgets import QDialogButtonBox, QFileDialog, QRadioButton

from mantidimaging.core.data.dataset import StrictDataset
from mantidimaging.gui.mvp_base import BaseDialogView
from mantidimaging.gui.windows.main.presenter import DatasetId

NXS_EXT = ".nxs"

Expand All @@ -18,7 +18,7 @@ class NexusSaveDialog(BaseDialogView):
floatRadioButton: QRadioButton
intRadioButton: QRadioButton

def __init__(self, parent, dataset_list: list[StrictDataset]):
def __init__(self, parent, dataset_list: list[DatasetId]):
super().__init__(parent, 'gui/ui/nexus_save_dialog.ui')

self.browseButton.clicked.connect(self._set_save_path)
Expand Down Expand Up @@ -51,16 +51,16 @@ def save_path(self) -> str:
def sample_name(self) -> str:
return str(self.sampleNameLineEdit.text())

def enable_save(self):
def enable_save(self) -> None:
self.buttonBox.button(QDialogButtonBox.StandardButton.Save).setEnabled(self.save_path().strip() != ""
and self.sample_name().strip() != "")

def _set_save_path(self):
def _set_save_path(self) -> None:
path = QFileDialog.getSaveFileName(self, "Save NeXus file", "", f"NeXus (*{NXS_EXT})")[0]
self.savePath.setText(path)
self._check_extension()

def _check_extension(self):
def _check_extension(self) -> None:
path = self.save_path()
if os.path.splitext(path)[1] != NXS_EXT:
self.savePath.setText(path + NXS_EXT)
Expand Down
Loading

0 comments on commit bdf37e9

Please sign in to comment.