diff --git a/.github/workflows/_dist.yml b/.github/workflows/_dist.yml index 6f59996..a6e9f68 100644 --- a/.github/workflows/_dist.yml +++ b/.github/workflows/_dist.yml @@ -18,7 +18,7 @@ jobs: pipx run build - name: Upload sdist and wheel as artifacts - uses: actions/upload-artifact@v5 + uses: actions/upload-artifact@v6 with: name: dist path: dist diff --git a/.github/workflows/_docs.yml b/.github/workflows/_docs.yml index 7885921..2b83997 100644 --- a/.github/workflows/_docs.yml +++ b/.github/workflows/_docs.yml @@ -30,7 +30,7 @@ jobs: run: rm build/html/.doctrees/environment.pickle - name: Upload built docs artifact - uses: actions/upload-artifact@v5 + uses: actions/upload-artifact@v6 with: name: docs path: build diff --git a/.github/workflows/_release.yml b/.github/workflows/_release.yml index 5801673..f9ca831 100644 --- a/.github/workflows/_release.yml +++ b/.github/workflows/_release.yml @@ -7,7 +7,7 @@ jobs: steps: - name: Download artifacts - uses: actions/download-artifact@v6 + uses: actions/download-artifact@v7 with: merge-multiple: true diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.yml index 1576ffb..32476d5 100644 --- a/.github/workflows/_test.yml +++ b/.github/workflows/_test.yml @@ -38,7 +38,7 @@ jobs: - if: inputs.python-version == 'dev' name: Upload dev-requirements.txt - uses: actions/upload-artifact@v5 + uses: actions/upload-artifact@v6 with: name: dev-requirements path: /tmp/dev-requirements.txt diff --git a/src/i19serial_ui/gui/serial_gui_eh2.py b/src/i19serial_ui/gui/serial_gui_eh2.py index ae8e52a..2bcb777 100644 --- a/src/i19serial_ui/gui/serial_gui_eh2.py +++ b/src/i19serial_ui/gui/serial_gui_eh2.py @@ -23,6 +23,7 @@ log_to_gui, tidy_up_logging, ) +from i19serial_ui.parameters.general_utils import ApertureOptions WINDOW_SIZE = (600, 1200) LOG_HANDLERS = [] @@ -126,9 +127,27 @@ def _setup_title(self): self.i19_label.setFont(QtGui.QFont(FONT, 13)) self.i19_label.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter) + def _create_dropdown(self): + self.aperturedropdown = QtWidgets.QComboBox() + self.aperturedropdown.addItems(list(ApertureOptions)) + self.selected_aperture = self.read_aperture_dropdown() + + def read_aperture_dropdown(self): + return self.aperturedropdown.currentText() + def _create_top_group(self): # move arrows, phi step, focuse, backlight etc + self._create_dropdown() self.top_group = QtWidgets.QGroupBox() + top_layout = QtWidgets.QGridLayout() + self.ddb_label = QtWidgets.QLabel("Select aperture size:") + self.ddb_label.setFont(QtGui.QFont(FONT, 10)) + self.ddb_label.setAlignment(QtCore.Qt.AlignmentFlag.AlignLeft) + top_layout.addWidget(self.ddb_label) + top_layout.addWidget(self.aperturedropdown) + self.top_group.setLayout(top_layout) + self.aperturedropdown.setFixedWidth(150) + top_layout.setColumnStretch(2, 1) def _create_coordinate_system_group(self): self.cs_group = QtWidgets.QGroupBox("Coordinate System") @@ -233,6 +252,7 @@ def run_panda(self): num_images = float(self.inputs.num_images.text()) rotation_increment = float(self.inputs.image_width.text()) rotation_end = rotation_start + num_images + rotation_increment + params = { "phi_start": rotation_start, "phi_end": rotation_end, diff --git a/src/i19serial_ui/parameters/general_utils.py b/src/i19serial_ui/parameters/general_utils.py new file mode 100644 index 0000000..ea96d92 --- /dev/null +++ b/src/i19serial_ui/parameters/general_utils.py @@ -0,0 +1,8 @@ +from enum import StrEnum + + +class ApertureOptions(StrEnum): + UM_20 = "20um" + UM_40 = "40um" + UM_100 = "100um" + UM_3000 = "3000um" diff --git a/tests/gui/test_eh2_ui.py b/tests/gui/test_eh2_ui.py index 1c288cb..4e7574a 100644 --- a/tests/gui/test_eh2_ui.py +++ b/tests/gui/test_eh2_ui.py @@ -29,6 +29,9 @@ def test_all_widgets_initialised(mock_eh2_gui): assert mock_eh2_gui.inputs and isinstance(mock_eh2_gui.inputs, InputPanel) assert mock_eh2_gui.wells and isinstance(mock_eh2_gui.wells, WellsSelectionPanel) assert mock_eh2_gui.grid and isinstance(mock_eh2_gui.grid, GridOptions) + assert mock_eh2_gui.aperturedropdown and isinstance( + mock_eh2_gui.aperturedropdown, QtWidgets.QComboBox + ) def test_general_layout(mock_eh2_gui): @@ -36,6 +39,15 @@ def test_general_layout(mock_eh2_gui): assert isinstance(mock_eh2_gui.general_layout, QtWidgets.QGridLayout) title = mock_eh2_gui.general_layout.children()[0] assert isinstance(title, QtWidgets.QHBoxLayout) + assert isinstance(mock_eh2_gui.top_group, QtWidgets.QGroupBox) + + +@pytest.mark.parametrize( + "aperture,index", [("20um", 0), ("40um", 1), ("100um", 2), ("3000um", 3)] +) +def test_dropdown_update(mock_eh2_gui, aperture, index): + mock_eh2_gui.aperturedropdown.setCurrentIndex(index) + assert mock_eh2_gui.read_aperture_dropdown() == aperture def test_select_visit(mock_eh2_gui): diff --git a/tests/gui/test_utils.py b/tests/gui/test_utils.py index c107072..72af089 100644 --- a/tests/gui/test_utils.py +++ b/tests/gui/test_utils.py @@ -1,3 +1,4 @@ +from datetime import datetime from pathlib import Path import pytest @@ -19,9 +20,10 @@ def test_create_icon(): def test_get_data_main_path(): + year = datetime.now().year res = get_data_main_path() - assert res.as_posix() == "/dls/i19-2/data/2025" + assert res.as_posix() == f"/dls/i19-2/data/{year}" def test_get_config_file_path_for_eh2():